Can anyone check my solution Id. 34415408. I don't know why it is giving TLE. Code link : http://codeforces.net/contest/86/submission/34415408
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | maomao90 | 163 |
2 | Um_nik | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
Can anyone check my solution Id. 34415408. I don't know why it is giving TLE. Code link : http://codeforces.net/contest/86/submission/34415408
Название |
---|
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.