Time limit getting exceeded.. plz help(PROXYC)

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

It gives the wrong answer for this testcase:

1
28
PAAAPPPAAPPAPPPAAPAAAPAPAAPP

Edit:

You edited the title since I posted :slight_smile: 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 :slight_smile:

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 :slight_smile: 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

No, we can’t - please read the rules carefully :slight_smile:

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 :slight_smile:

1 Like