Блог пользователя Chiefash

Автор Chiefash, история, 12 месяцев назад, По-английски

I was trying to solve problem C in Educational Codeforces Round 159 (Rated for Div. 2).

Here I just wanted to check if the value i is not present in the array. I tried using three things 1. I created an unordered_set of all elements in the array and used !s.count(i) to check if the value is present or not? 2. I created an unordered_map of all elements in the array and used mp[i] == 0 to check if the value is present or not 3. Finally I used lower_bound function on the array to check if the value is present or not.

I got TLE on first two but accepted in third. Can someone please explain why is this happening. I don't want to make the same mistake again in the contest.

I am adding images for all examples.

image1 image2 image3

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится