問題一覧 > 通常問題

No.733 Parallel Coding with Clones

レベル : / AI推定難易度 : 1575 / 実行時間制限 : 1ケース 1.500秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 97
作問者 : りあん / テスター : conf
お気に入りにしたユーザー ProblemId : 1132 / 自分の提出
問題文最終更新日: 2018-09-07 07:53:45
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 199 (順位表) の他の問題:

Disclaimer

The intended solution gets TLE in Python3, but it has been confirmed to get AC when submitted in PyPy3.

Problem Statement

Rian-kun is a descendant of ninja and is able to create clones of himself.

Today Rian-kun is participating in a programming contest, and after some thinking, he has figured out the solutions to all the problems and the time needed to code each of them. However, he spent so much time thinking that only $T$ minutes remain for coding.

So he has decided to use his specialty, cloning, to code in parallel. However, both cloning and preparing a PC for each person cost something, so he wants to keep the number of clones as small as possible.

Therefore, find the minimum number of clones required to solve all the problems within the time limit (that is, how many people coding in parallel are needed to solve all the problems in time).


Note that code cannot be copied and pasted between PCs, so each problem must not be split across multiple PCs and must be written entirely on one PC.

Input

$T$
$N$
$t_1$
:
$t_N$

The first line gives the remaining contest time $T$.

The second line gives the number of problems $N$.

In the following $N$ lines, starting from the third line, the time $t_i$ needed to implement the $i$-th problem is given.

All input values are integers and satisfy the following constraints.

  • $1 \le T \le 2000$
  • $1 \le N \le 17$
  • $1 \le t_i \le T$

Output

Output the minimum number of clones required to solve all the problems within the time limit.

Print a newline at the end.

Sample

Sample 1
Input
5
3
1
5
3
Output
2

If the first person solves the 1st and 3rd problems and the second person solves the 2nd problem, two people can solve all the problems in time.

Sample 2
Input
9
4
5
5
5
5
Output
4

Each person can solve only one problem.

Sample 3
Input
10
6
2
2
2
3
5
6
Output
2

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。