12 条题解

  • 1
    @ 2025-11-7 20:39:14
    #include <bits/stdc++.h>
    using namespace std;
    int main(){
        int s,i;
        scanf("%d",&s);
        while(s--){
            int w,n,temp,a[300];
            scanf("%d%d",&w,&n);
            temp=n-1;
            for(i=0;i<n;i++){
                scanf("%d",&a[i]);
            }
            sort(a,a+n);
            for(i=0;temp>i;){
                if(a[i]+a[temp]<=w){n--;i++;temp--;}
                else temp--;
            }
            printf("%d\n",n);
        }
    }
    
    • @ 2025-11-7 20:40:55

      sort排序一下so easy 不想用sort就用冒泡排列一样的,不知道啥叫冒泡排序就自己想办法把一个数组里的数从小到大排序

信息

ID
148
时间
3000ms
内存
128MiB
难度
6
标签
(无)
递交数
592
已通过
199
上传者