#P13646. [NOISG 2016] LunchBox

[NOISG 2016] LunchBox

题目描述

You are the manager of a restaurant. You prepare NN lunch boxes and hope to distribute them to some schools. Suppose there are mm schools and assume the iith school asks for kik_i lunch boxes.

You aim to distribute the lunch boxes to as many schools as possible. Moreover, you have a rule. For the iith school, you give either zero or kik_i lunch boxes. Can you make a program that help you to find the maximum number of schools that can receive lunch boxes?

输入格式

Your program must read from standard input. The first line contains 2 integers, NN and mm. Then, it follows by mm lines. The iith line contains an integer kik_i.

输出格式

Your program must output one line with a single integer to the standard output, which is the maximum number of schools.

10 4
3
9
4
2
3

提示

Sample Explanation

In this example, the answer is 33 since 3+4+2103 + 4 + 2 \leq 10 and 3+9+4+2>103 + 9 + 4 + 2 > 10.

Subtasks

The maximum execution time on each instance is 0.5s0.5s. Your program will be tested on sets of input instances that satisfies the following restrictions:

Subtask Marks Restrictions
1 20 Each instance satisfies m=1m = 1, 0<N600000 < N \leq 60000 and 0<ki300000 < k_i \leq 30000
2 30 Each instance satisfies 0<m10000 < m \leq 1000, 0<N600000 < N \leq 60000 and 0<ki10000 < k_i \leq 1000
3 50 Each instance satisfies 0<N0 < N, m60000m \leq 60000 and 0<ki300000 < k_i \leq 30000