| 比赛 | test1 | 评测结果 | AAAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 纪念品分组 | 最终得分 | 100 |
| 用户昵称 | 皓芷 | 运行时间 | 0.053 s |
| 代码语言 | C++ | 内存使用 | 0.39 MiB |
| 提交时间 | 2017-02-28 19:54:50 | ||
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=30010;
int w,n,a[maxn],ans=0;
int main()
{
freopen("group.in","r",stdin);
freopen("group.out","w",stdout);
scanf("%d%d",&w,&n);
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
for(int i=0,j=n;i<j;)
if(a[j-1]+a[i]<=w){ans++;i++;j--;}
else {ans++;j--;}
printf("%d",ans);
return 0;
}