GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Thursday, 11 August 2022

[Solution] Mark and Professor Koro Codeforces Solution




E. Mark and Professor Koro
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

After watching a certain anime before going to sleep, Mark dreams of standing in an old classroom with a blackboard that has a sequence of n positive integers a1,a2,,an on it.

Then, professor Koro comes in. He can perform the following operation:

  • select an integer x that appears at least 2 times on the board,
  • erase those 2 appearances, and
  • write x+1 on the board.

Professor Koro then asks Mark the question, "what is the maximum possible number that could appear on the board after some operations?"

Mark quickly solves this question, but he is still slower than professor Koro. Thus, professor Koro decides to give Mark additional challenges. He will update the initial sequence of integers q times. Each time, he will choose positive integers k and l, then change ak to l. After each update, he will ask Mark the same question again.

Solution Click Below:-  👉CLICK HERE👈
👇👇👇👇👇

Help Mark answer these questions faster than Professor Koro!

Note that the updates are persistent. Changes made to the sequence a will apply when processing future

Mark and the Online Exam Codeforces Solution

Mark and Professor Koro Codeforces Solution

Mark and Lightbulbs Codeforces Solution

Mark and His Unfinished Essay Codeforces Solution

Mark the Dust Sweeper Codeforces Solution

Mark the Photographer Codeforces Solution

 updates.

Input

The first line of the input contains two integers n and q (2n21051q2105) — the length of the sequence a and the number of updates, respectively.

The second line contains n integers a1,a2,,an (1ai2105)

Then, q lines follow, each consisting of two integers k and l (1kn1l2105), telling to update ak to l.

Output

Print q lines. The i-th line should consist of a single integer — the answer after the i-th update.

No comments:

Post a Comment