Cowmpetency
My Original Pseudo-Code
take in input
make a copy of the original c array, make all changeable values 1
sort the Q pairs by a
for each Q pair:
find the max value in the section from 1 to a: P
check all the numbers between a and b for a number that's greater than the max
work back from a to the beginning of the section, and change the first one that's changeable to be equal to the one that's greater than the max
if there is
set b equal to 1+ that
if there are no changeable ones:
-1
else
make b equal to 1+ the max
final pass where you try to lower all the numbers if possible, check to see that everything is correct (including that upper_bound C constraint)
Last updated