piyush1_1_23's blog

By piyush1_1_23, history, 23 months ago, In English
    • for (int i = 0; i < n; i++) {
    • ll rightMax = query(prefixTree, 1, 0, _n — 1, i + 1, ng[i] — 1) — prefixSum[i];
    • ll leftMax = query(suffixTree, 1, 0, _n — 1, pg[i] + 1, i — 1) — suffixSum[i];
    • if (max(leftMax, rightMax) > 0) {
    • flag = false;
    • break;
    • }
    • }

Problem Link Editorial Link

why they are selecting the lower index as i + 1 but not i. According to me it was something like

ll rightMax = query(prefixTree, 1, 0, _n — 1, i, ng[i] — 1) — prefixSum[i-1];**

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it