• For each number, find out the range where it is the largest
  • For each number in left part, find out what least amount is needed in right part to surpass the max value of this part and store right part {start point, end point}
  • Or do vice-versa in case right part has less elements
  • There can be as much as n(lg(n))n(lg(n)) such pairs
  • Now build a segment tree and assume all the numbers are dead at the beginning
  • Keep making numbers alive in descending order
  • Use stored {start point, end point}s to make query when all the numbers more or equal needed by respective {start point, end point} are added to the segment tree
  • For each segment, the max value can pair up with a number from the left or right part as well. Take care of that case.

Complexity can go up to n(lg(n))2n{(lg(n))}^2.

Statistics

58% Solution Ratio
IOI_StfuFfsEarliest, May '18
nusuBotFastest, 0.3s
Tarik.amtolyLightest, 4.1 MB
solaimanopeShortest, 1382B
Toph uses cookies. By continuing you agree to our Cookie Policy.