问题 V: Marathon

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:213 解决:53

题目描述


Your ACM career is like a marathon,

Willing to step on the field, you are a brave person;

Holding on to the end, you are a strong person.

There are setbacks and hardships along the way, and of course, there is also joy of victory, a beautiful memory and good gayfriends.

Now, Juruo WHY has a tough task:

He gives you n tracks, whose lengths are
a1,a2,a3, ..., an (unit: km). 

You need to select some of the tracks and splice(拼接) them into a marathon course (the spliced length is the sum of the lengths of the tracks you selected). What is the minimum number of tracks you need to select?

It is well known that a marathon course is 42.195km long. To simplify the problem, you only need to make a 42km long course. So the problem is easy: select minimum tracks whose lengths sum up to 42km.

Since WHY is a vegetable dog and he doesn't know algorithms like DP or DFS, he asks you to solve this problem.



输入

The input has 2 lines. 

The first line is an integer n ( 1 <= n <= 5,000 ), denoting the number of tracks you have.

The second line contains n intergers a1,a2,a3, ..., an  (0 <= ai <= 100), denoting the lengths of the tracks.

输出

The output is an integer representing the minimum number of tracks required to splice a 42km cource.

If the given tracks cannot be spliced into $42km$, please output QwQ

样例输入 复制

5
15 20 24 18 7

样例输出 复制

2

提示

[Explaination of Sample]

Both 15,20,7 and 24,18 can sum up to 42. But you need to minimize the number of tracks selected, so the answer is 2.


来源/分类