MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / merge

Method merge

src/class161/Code06_Tourism1.java:235–244  ·  view source on GitHub ↗
(int[] ans, int rmax, int rmin, int rlpro, int rrpro)

Source from the content-addressed store, hash-verified

233 // rrpro : 线段树更右侧部分的rprofit
234 // 左侧部分和右侧部分的信息整合在一起得到整个范围的max、min、lprofit、rprofit
235 public static void merge(int[] ans, int rmax, int rmin, int rlpro, int rrpro) {
236 int lmax = ans[0];
237 int lmin = ans[1];
238 int llpro = ans[2];
239 int lrpro = ans[3];
240 ans[0] = Math.max(lmax, rmax);
241 ans[1] = Math.min(lmin, rmin);
242 ans[2] = Math.max(Math.max(llpro, rlpro), rmax - lmin);
243 ans[3] = Math.max(Math.max(lrpro, rrpro), lmax - rmin);
244 }
245
246 // ans[0] : 线段树更左侧部分的max
247 // ans[1] : 线段树更左侧部分的min

Callers 2

queryMethod · 0.95
computeMethod · 0.95

Calls 1

maxMethod · 0.45

Tested by

no test coverage detected