My code for 903D - Almost Difference has got Time limits. My solution is 33798061, but I could not fix the problem. Can anyone help me? This is my code : CODE
My code for 903D - Almost Difference has got Time limits. My solution is 33798061, but I could not fix the problem. Can anyone help me? This is my code : CODE
# | User | Rating |
---|---|---|
1 | tourist | 3690 |
2 | jiangly | 3647 |
3 | Benq | 3581 |
4 | orzdevinwang | 3570 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | Radewoosh | 3509 |
8 | ecnerwala | 3486 |
9 | jqdai0815 | 3474 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 174 |
2 | awoo | 164 |
3 | adamant | 163 |
4 | TheScrasse | 159 |
5 | nor | 157 |
6 | maroonrk | 155 |
7 | -is-this-fft- | 152 |
8 | Petr | 146 |
8 | orz | 146 |
10 | BledDest | 145 |
Name |
---|
Your solution is O(n2) and 1 ≤ n ≤ 200000. That is not nearly fast enough to run under 2 seconds. If you want, you could try reading the editorial to that problem: http://codeforces.com/blog/entry/56330.
It gives a solution. This is not a simple problem which can be brute forced. If you happen to want to do those sort of problems, look at problems A and B in Div. 2 rounds.
Best of luck!