Alex and Requests
Practice
3 (8 votes)
Ad Hoc
Approved
Easy
Priority queue
Approved
Problem
63% Success 5571 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Alex is working in a firm, where he needs to process requests according to their priority. He has N allocation systems. At any instance, \(i^{th}\) system can process only one request with priority i or above.

For each request, on any eligible system, Alex can also terminate the request with less priority than that of the current request, in order to assign the current request to the system. There will be Q incoming requests and he needs to tell whether he can assign a system to each request or not.

Alex needs to assign each request to the system optimally, such that he can assign maximum number of incoming requests. The number of requests (which are already assigned) terminated by Alex, doesn't matter here.

Note:
If not terminated explicitly, consider the processing time of every request as infinite.

Input Format:

First line of the input contains N, denoting the number of allocation systems.

Next line contains one integer Q, which denotes the number of incoming requests.

In next Q lines, each line contains one integer X, denoting the priority of the request.

Output Format:

For each incoming request, in new line print \(YES\), if Alex can assign a system to the request, else print \(NO\) .

Note:

If Alex can anyhow assign the current request to the system, he can't reject the request. It is necessary to assign the request to any system.

Constraints:
\(1 \le N \le 100\)
\( 1 \le X \le 100000\)
\( 1 \le Q \le 10000\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
32 votes
Tags:
EasyMaps
Points:20
27 votes
Tags:
ImplementationBasic ProgrammingBasic Math
Points:20
15 votes
Tags:
Basic Programming