PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000304. Thành lập hội đồng học sinh (Student Councils)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Thành lập hội đồng học sinh (Student Councils)

Student Councils

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn groups with aia_i students in group i. Each council must have exactly kk students from distinct groups. A student may belong to at most one council or remain unused. Maximize the number of councils. This PHOJ adaptation uses locally defined limits.

Input

First line: k,nk,n, in this order. Second line: nn integers aia_i.

Output

Print the maximum number of councils.

Subtasks

  • Subtask 1 (20 points): 1≤k≤n≤51\le k\le n\le5; 0≤ai≤40\le a_i\le4.
  • Subtask 2 (30 points): 1≤k≤n≤2⋅1051\le k\le n\le2\cdot10^5; 0≤ai≤1090\le a_i\le10^9; a1=⋯=ana_1=\cdots=a_n.
  • Subtask 3 (50 points): 1≤k≤n≤2⋅1051\le k\le n\le2\cdot10^5; 0≤ai≤1090\le a_i\le10^9.

Examples

Input 1

2 3
4 2 1

Output 1

3

Explanation

Use groups 1 and 2 twice, then groups 1 and 3 once. Seven students cannot fill four councils.