13 条题解

  • 0
    @ 2025-12-8 17:20:41

    #include<stdio.h> #include<algorithm> using namespace std; int main() { int a; scanf("%d",&a); while(a--) { int w,n,i=0; scanf("%d %d",&w,&n); int s[300]; for(i=0;i<n;i++) { scanf("%d",&s[i]); } sort(s,s+n); int temp=n-1; while(temp>i) { if(s[i]+s[temp]<=w) { n--; i++; temp--; } else temp--; } printf("%d\n",n); } return 0; }

    信息

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