8 条题解
-
0
#include <stdio.h>
int main() {
int s; scanf("%d",&s); while(s--){ int w,n; scanf("%d %d",&w,&n); int a[n]; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } for(int i=0;i<n;i++){ for(int j=0;j<n-1-i;j++){ int temp=0; if(a[j]>a[j+1]){ temp=a[j]; a[j]=a[j+1]; a[j+1]=temp; } } } int count=0; int b=n-1; for(int i=0;i<=b;i++){ if(a[i]+a[b]<=w){ count++; b--; }else{ b--; i--; count++; } } printf("%d\n",count); } return 0; }
信息
- ID
- 148
- 时间
- 3000ms
- 内存
- 128MiB
- 难度
- 6
- 标签
- (无)
- 递交数
- 519
- 已通过
- 172
- 上传者