Question: write a java code Input file: standard input Output file: standard output *Time Complexity does not include read and write operations Coach Ahmad organizes some

write a java code

write a java code Input file: standard input Output file: standard output

Input file: standard input Output file: standard output *Time Complexity does not include read and write operations Coach Ahmad organizes some local programming competitions. Each competition contains n questions of distinct difficulty, which are numbered from 1 to n. To hold a competition, Coach Ahmad must choose n new (unused previously) questions, one for each difficulty level. Now, Coach Ahmad writes the questions himself, but he cannot write a question of specific difficulty. Instead, after completing the question, he rates its difficulty from 1 to n and adds it to the questions pool. Each time Coach Ahmad selects a set of n questions with a distinct level of difficulty from the pool, he uses them in a competition and then removes them from the pool. Coach Ahmad always writes one question at a time, so if he can organize a competition immediately after creating a question, he does so. You are given a set of questions' difficulties in the order determined by Coach Ahmad. For each question, determine whether Coach Ahmad organize the competition immediately after creating this question or not. The question pool is initially empty. Input The first line contains two integers, n, and m(1n,m105) - the number of difficulty levels and the number of questions coach Ahmad created. The second line contains m integers a1,a2,am(1a1n) - the questions' difficulties in the order determined by Coach Ahmad. Output Print a line containing m digits. The i-th digit should be 1 if Coach Ahmad organizes the competition after the writing of the i-th question, and 0 otherwise. Example Note In the first example Coach Ahmad organized the competition after the first three questions, because they are of distinct difficulties, and then only after the last

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!