Lunch boxes
Practice
3.2 (39 votes)
Implementation
Basic programming
Sorting
Basics of greedy algorithms
Basics of implementation
Problem
92% Success 12578 Attempts 10 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Alice works as a restaurant manager. The restaurant has prepared \(N\) lunch boxes and Alice plans to distribute them to some schools. Consider that there are \(M\) schools and an \(i^{th}\) school orders \(A_i\) lunch boxes.

She wants to distribute lunch boxes to as many schools as possible. Also, she has the following rule:

  • For an \(i^{th}\) school, she gives either zero or \(A_i\) lunch boxes

Your task is to help Alice to determine the maximum number of schools that can get lunch boxes.

Input format    

  • The first contains an integer \(t\) that denotes the number of test cases in the input.
  • Each test case consists of two lines:
    • The first line contains two integers \(N\) and \(M\).
    • The second line contains \(M\) integers \(A_1,A_2,...,A_m\).

Output format

For each test case, you are required to print one integer that represents the maximum number of schools that can receive lunch boxes.

Constraints

\(1≤t≤10\)

\(1≤N,M≤10^5\)

\(1≤A_i≤10^6,1≤i≤M\)

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:10
81 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementation
Points:10
89 votes
Tags:
ImplementationBasic Programming
Points:10
41 votes
Tags:
AlgorithmsSortingString Manipulation