Can anyone check my solution Id. 34415408. I don't know why it is giving TLE. Code link : http://mirror.codeforces.com/contest/86/submission/34415408
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 170 |
2 | Um_nik | 162 |
3 | maomao90 | 161 |
4 | atcoder_official | 160 |
5 | djm03178 | 158 |
5 | -is-this-fft- | 158 |
7 | adamant | 154 |
7 | Dominater069 | 154 |
9 | awoo | 152 |
9 | luogu_official | 152 |
Can anyone check my solution Id. 34415408. I don't know why it is giving TLE. Code link : http://mirror.codeforces.com/contest/86/submission/34415408
Name |
---|
Auto comment: topic has been updated by ryuga222 (previous revision, new revision, compare).
First of all notice that this is an old problem. So your execution time will be multiplied by 2.
There are many optimizations that you can do —
scanf/printf
for IO.long long
variables, it takes too much time. Use only when necessary.long long BLOCK = 512
, if you useconst long long
compiler will optimize division / modulo for with the number.cnt[]
array 5 times inadd/remove
function. But it is possible to design those by accessing only twice or even once.i++
, and changing it to++i
doesn't affect much. Then use++i
. Somehow++i
is more faster.So, it is reasonable that you got TLE.
damn... it worked when i optimized the add/remove function. Can't believe it was giving TLE. Thanks a lot :D.
how i can pre-calculate the BLOCK in main function?? i don't understand that.
Take another array
blc[]
, and precalculate likeblc[i] = i / block_size;
, then use this array in compare function.