Doubt in unordered_map vs map in C++

Revision en1, by RP_9, 2020-04-09 07:45:42

Hello Codeforces,

I was trying to solve Codeforces Round #632 (Div. 2) Problem C. It gave me TLE on the last case (87th case) when I used unordered_map (Link) while it was accepted when I used map (Link).

I know the worst-case time complexity of the unordered_map is O(n) for searching, insertion, and deletion. Is the last case the worst case? Could someone help me to figure out how this is happening or where I'm getting wrong?

Tags map vs unordered_map, c++, c++ 11, c++14, c++17

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English RP_9 2020-04-09 07:45:42 639 Initial revision (published)