# Time limit getting exceeded.. plz help(PROXYC)

It gives the wrong answer for this testcase:

1
28
PAAAPPPAAPPAPPPAAPAAAPAPAAPP



Edit:

You edited the title since I posted However, the linked submission:

https://www.codechef.com/viewsolution/30703545

is WA, not TLE.

2 Likes

i am getting output 7 … is it wrong . plz check this is my new code…
https://www.codechef.com/viewsolution/30705864

7 is correct, but your original code gave 9

Edit:

Your submission https://www.codechef.com/viewsolution/30705864 gives a TLE, and the wrong answer for this testcase:

1
8
AAAAPAAP

2 Likes

for that my output is coming 4… what should be the answer and how to remove TLE?

-1

Write faster code Your solution looks like it’s O(T \times D^2), and with D=1000 and T=200, this is going to be fairly tight in C++, and probably not possible with Python (the amount of time taken by a Python solution is immensely variable).

A O(T \times D) solution is possible, so aim for that.

1 Like

OK but i think the answer 4 is right as we can hit proxies on the two A’s between the two P’s and the 2 A’s left of the Left P.
AAAAPAAP

The only day he can be marked as present by proxy is day 6:

AAAAPAAP
^


Edit:

The sentence:

is badly worded - it means he cannot be marked as present-by-proxy on any of the following days: day 1; day 2; day D-1; day D. Although I guess this is kind of implicit, anyway

1 Like