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 | 3845 |
2 | jiangly | 3707 |
3 | Benq | 3630 |
4 | orzdevinwang | 3573 |
5 | Geothermal | 3569 |
5 | cnnfls_csy | 3569 |
7 | jqdai0815 | 3532 |
8 | ecnerwala | 3501 |
9 | gyh20 | 3447 |
10 | Rebelz | 3409 |
# | User | Contrib. |
---|---|---|
1 | maomao90 | 168 |
2 | awoo | 163 |
3 | adamant | 162 |
4 | maroonrk | 152 |
5 | nor | 151 |
5 | -is-this-fft- | 151 |
7 | atcoder_official | 147 |
7 | TheScrasse | 147 |
9 | Vladosiya | 146 |
10 | Petr | 145 |
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
.