| 比赛 | NOIP2007普及组(复现) | 评测结果 | AAAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 纪念品分组 | 最终得分 | 100 |
| 用户昵称 | AGNING | 运行时间 | 0.081 s |
| 代码语言 | C++ | 内存使用 | 13.77 MiB |
| 提交时间 | 2020-02-09 16:56:01 | ||
#include<bits/stdc++.h>
using namespace std;
int a[30030];
int n,w,ans,top,rot;
int main(){
freopen("group.in","r",stdin);
freopen("group.out","w",stdout);
while(cin>>w>>n){
for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
ans=0,top=0,rot=n-1;
while(top<=rot)
if(a[top]+a[rot]<=w){
top++,rot--,ans++;
}
else{
rot--,ans++;
}
cout<<ans;
}
return 0;
}