Hi everyone. I'm getting the right answer on the first couple of test cases on a fairly easy problem but on the third one I get "time limit exceeded". Here's my submission: https://codeforces.com/contest/1325/submission/82660385 . If anybody can think of a way to make my solution more efficient it would help a lot!
Thank you very much.