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

Автор redcoder23, история, 6 лет назад, По-английски

An array is given (indexing starts with 1) of size S and N number of queries is given by user Ni=(M P R); 1<=i<=N. Print the Rth minimum element from the array after updating Mth index. Example :- Array : [2, 4, 6, 1, 7] S=5

Queries : N=3

2 5 3

5 3 2

4 8 4

Output :- 5

2

6

How to solve this question.

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

»
6 лет назад, скрыть # |
← Rev. 7  
Проголосовать: нравится +11 Проголосовать: не нравится

Use this https://codeforces.me/blog/entry/11080. Or maintain a segtree where a_x = no of elements equal to x then slightly modify technique from this article https://cp-algorithms.com/data_structures/segment_tree.html (Counting the number of zeros, searching for the k -th zero section) to find k-th element or just binary search.