yukicoder-5

从 Trac 迁移的文章

这是从旧校内 Wiki 迁移的文章,可能存在一些样式问题,您可以向 memset0 反馈。

原文章内容如下:

{{{
#!html
<script type="text/x-mathjax-config">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}});</script>
<script type="text/javascript" async src="http://10.71.10.90/sfiction/tool/MathJax/MathJax-master/MathJax.js?config=TeX-MML-AM_CHTML"></script>
<style>
.input, pre {
    display: block;
    padding: 9.5px;
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.42857143;
    color: #333;
    word-break: break-all;
    word-wrap: break-word;
    background-color: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 4px;
}
</style>
}}}

== [https://yukicoder.me/problems/no/5 No.5 数字のブロック] ==

=== Description ===

{{{
#!html
<p>有$N$个物品,第$i$个的高度是$1$,款是$W_i$。现在有一个高为$1$,宽为$L$的盒子,求最多能放进去多少个物品。</p>
}}}

=== Input ===

{{{
#!html
<p class="input">
$L$<br>
$N$<br>
$W_1$ $W_2$ $W_3$ $\dots$ $W_N$
</p>

<p>$2 \le N, L \le 10000, 1 \le W_i \le L$</p>
}}}

=== Output ===

{{{
#!html
<p>输出最多能放进去的物品个数。</p>
}}}

=== Sample ===

==== Sample 1 ====
输入
{{{
#!html
<pre>
16
3
10 5 7
</pre>
}}}
输出
{{{
#!html
<pre>
2
</pre>
}}}

==== Sample 2 ====
输入
{{{
#!html
<pre>
100
10
14 85 77 26 50 45 66 79 10 3
</pre>
}}}
输出
{{{
#!html
<pre>
5
</pre>
}}}

No.5 数字のブロック

Description

有$N$个物品,第$i$个的高度是$1$,款是$W_i$。现在有一个高为$1$,宽为$L$的盒子,求最多能放进去多少个物品。

Input

$L$
$N$
$W_1$ $W_2$ $W_3$ $\dots$ $W_N$

$2 \le N, L \le 10000, 1 \le W_i \le L$

Output

输出最多能放进去的物品个数。

Sample

Sample 1

输入

16310 5 7

输出

2
Sample 2

输入

1001014 85 77 26 50 45 66 79 10 3

输出

5