Hello Codeforces, I participated in contest and i wrote a solution which seems like O(nlogn) to me but I still got TLE despite of constraints for N being 10^6. Can anyone Help me figure out why I got TLE and how can I fix it. Submission Link :
# | User | Rating |
---|---|---|
1 | tourist | 3803 |
2 | jiangly | 3707 |
3 | Benq | 3627 |
4 | ecnerwala | 3584 |
5 | orzdevinwang | 3573 |
6 | Geothermal | 3569 |
6 | cnnfls_csy | 3569 |
8 | Radewoosh | 3542 |
9 | jqdai0815 | 3532 |
10 | gyh20 | 3447 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 165 |
2 | awoo | 164 |
3 | adamant | 162 |
4 | maroonrk | 152 |
5 | -is-this-fft- | 151 |
5 | nor | 151 |
7 | atcoder_official | 147 |
8 | TheScrasse | 146 |
9 | Petr | 145 |
10 | SecondThread | 142 |
Hello Codeforces, I participated in contest and i wrote a solution which seems like O(nlogn) to me but I still got TLE despite of constraints for N being 10^6. Can anyone Help me figure out why I got TLE and how can I fix it. Submission Link :
Name |
---|
It is because of multiset, read this blog https://mirror.codeforces.com/blog/entry/122960
But i haven't used count in my solution :(
Btw i am the same person this is my alt account :D
The bounds for this problem were a little too tight I am assuming, which led to the constant factor in time complexities also play a role, I had made an O(nlogn) submission without including
ios_base::sync_with_stdio(false); cin.tie(nullptr);
and it didn't pass, but after including this block guess what, it did.
Normally this should not be a factor but due to the tight bounds it did for some reason
I had also tried an O(n) solution, but without the 2 lines mentioned above and it still didn't pass
Use fast IO for
cin/cout
or, useScanf/Printf
.