№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 3993 |
2 | jiangly | 3743 |
3 | orzdevinwang | 3707 |
4 | Radewoosh | 3627 |
5 | jqdai0815 | 3620 |
6 | Benq | 3564 |
7 | Kevin114514 | 3443 |
8 | ksun48 | 3434 |
9 | Rewinding | 3397 |
10 | Um_nik | 3396 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 155 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
10 | nor | 152 |
Название |
---|
This problem is a multiple test case problem, and it has a constraint on the limit of the sum of all $$$k_i$$$, so if you use a
map
the total number of elements inserted in the map will also not exceed that value. However, if you use avector
of size $$$2 \cdot 10^5$$$, it means you're also having a lot of unused indices which also takes some time to be allocated and initialized. In the worst case, with $$$10^5$$$ test cases, the sum of the size of these vectors will be $$$2 \cdot 10^{10}$$$, which is too large to be created within the time limit.I was thinking of O(1) lookup using vector compared to map, but as you highlighted the excessive vector creation over test cases, makes sense now. Thanks
If you want to achieve that $$$O(1)$$$ lookup you can do this instead: 293426305
Make the vector once in the global scope, and initialize each used indices after each test case.
yeah i saw your submission just now, making the vector global and resetting the used indexes after each test case. :D