GUPTA MECHANICAL

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

Saturday, 20 August 2022

[Solution] Monoblock Codeforces Solution| Solution Codeforces



C. Monoblock
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Stanley has decided to buy a new desktop PC made by the company "Monoblock", and to solve captcha on their website, he needs to solve the following task.

The awesomeness of an array is the minimum number of blocks of consecutive identical numbers in which the array could be split. For example, the awesomeness of an array

  • [1,1,1] is 1;
  • [5,7] is 2, as it could be split into blocks [5] and [7];
  • [1,7,7,7,7,7,7,7,9,9,9,9,9,9,9,9,9] is 3, as it could be split into blocks [1][7,7,7,7,7,7,7], and [9,9,9,9,9,9,9,9,9].

You are given an array a of length n. There are m queries of two integers ix. A query ix means that from now on the i-th element of the array a is equal to x.

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


Input

In the first line you are given with two integers n and m (1n,m105).

The second line contains n integers a1,a2,,an (1ai109) — the array a.

In the next m lines you are given the descriptions of queries. Each line contains two integers i and x (1in1x109).

Output

Print the answer to each query on a new line.

No comments:

Post a Comment