GUPTA MECHANICAL

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

Saturday 16 July 2022

[Solution] Doremy's IQ Codeforces Solution




C. Doremy's IQ
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Doremy is asked to test n contests. Contest i can only be tested on day i. The difficulty of contest i is ai. Initially, Doremy's IQ is q. On day i Doremy will choose whether to test contest i or not. She can only test a contest if her current IQ is strictly greater than 0.

If Doremy chooses to test contest i on day i, the following happens:

  • if ai>q, Doremy will feel she is not wise enough, so q decreases by 1;
  • otherwise, nothing changes.
If she chooses not to test a contest, nothing changes.

Doremy wants to test as many contests as possible. Please give Doremy a solution.

Input

The input consists of multiple test cases. The first line contains a single integer t (1t104) — the number of test cases. The description of the test cases follows.

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

The first line contains two integers n and q (1n1051q109) — the number of contests and Doremy's IQ in the beginning.

The second line contains n integers a1,a2,,an (1ai109) — the difficulty of each contest.

Difference Operations Codeforces Solution

Difference of GCDs Codeforces Solution

Doremy's IQ Codeforces Solution

Difference Array Solution Codeforces 

Partial Virtual Trees Codeforces Solution

DFS Trees Codeforces Solution

It is guaranteed that the sum of n over all test cases does not exceed 105.

Output

For each test case, you need to output a binary string s, where si=1 if Doremy should choose to test contest i, and si=0 otherwise. The number of ones in the string should be maximum possible, and she should never test a contest when her IQ is zero or less.

If there are multiple solutions, you may output any.

No comments:

Post a Comment