some features first.
think in your code, you are using 2 vectores, one only to take the signed of an integer..
why dont you take both to one?
Ok, another discusion is to see why you take
and your vectors are only INT. what happen if they give you unsigned longs as inputs, your program wont break, but gonna WA.
Another way can be you have one device that suply energy, its means that start from negative number, and only has 1 sequence that turn on that device, this means your max energy consumption will be negative, and you asume that start from zero, then this case will never pass.
im gonna solve this problem, when i get AC or PE i will report to you
only i have seen some cases will be exploit.
try to solve myself, later take it part of contest.