So, I was recently trying to solve this problem:↵
http://codeforces.net/contest/727/problem/F↵
submission at http://codeforces.net/contest/727/submission/21647053↵
↵
My algorithm should be O($n^2 * log 10^12 + m\ log\ n$). First, I determine the lowest possible prefix sum for a certain amount of removed problems. This is done with a binary search and greedy. I binary search on the condition "If we can remove a certain number of problems, can the minimum prefix sum be greater than or equal to the target?" (This is always of form TTTT...FFF). To find that condition I greedily add numbers to a running sum, and if the running sum is less than or equal to target, I remove the smallest value that occurs before or at the current index. Then, I read all m queries and binary search for the correct answer on those.↵
↵
Can anyone help me understand why I'm getting TLE? Thanks.
http://codeforces.net/contest/727/problem/F↵
submission at http://codeforces.net/contest/727/submission/21647053↵
↵
My algorithm should be O($n^2 * log 10^12 + m
↵
Can anyone help me understand why I'm getting TLE? Thanks.