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

Автор decoder__, история, 4 года назад, По-английски

Here is my code https://codeforces.me/contest/681/submission/91075066 for the question https://codeforces.me/problemset/problem/681/C. Can anyone help me that use of which thing is causing the MLE and which data structure should be used to avoid MLE?

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

»
4 года назад, # |
Rev. 2   Проголосовать: нравится 0 Проголосовать: не нравится

Use a multiset or a priority queue. Insert and removeMin are straightforward now.

For getMin, keep on removing the smallest element and keep on incrementing the count until the removed element is smaller than the getMin output given.

If now, the multiset is empty or the smallest element in it is greater than the getMin output given increase count by 1 (it accounts for adding the getMin output given by an insert operation).