比赛 |
test1 |
评测结果 |
AAAAAAAAAAA |
题目名称 |
纪念品分组 |
最终得分 |
100 |
用户昵称 |
Hyoi_0Koto |
运行时间 |
0.056 s |
代码语言 |
C++ |
内存使用 |
0.39 MiB |
提交时间 |
2017-02-28 19:54:56 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<algorithm>
- using namespace std;
- int a,b[30001],n,ans=0,h=0,t;
- void input(){
- cin>>a>>n;
- for(int i=1;i<=n;i++) scanf("%d",&b[i]);
- }
- void work(){
- sort(b+1,b+n+1);t=n;
- while(h<t){
- if(b[h]+b[t]>a){
- t--;ans++;
- }
- else{
- h++;t--;ans++;
- }
- }
- if(h==t) cout<<ans+1;
- else cout<<ans;
- }
- int main(){
- freopen("group.in","r",stdin);
- freopen("group.out","w",stdout);
- input();
- work();
- return 0;
- }