Problem H: tmk买礼物

传送门:http://gdutcode.sinaapp.com/problem.php?cid=1057&pid=7

题解:

实现代码;

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAXN=1000010;
int a[MAXN];


int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        int n;
        scanf("%d",&n);
        for(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        long long ans=0;
        for(int i=0;i<n&&a[i]<=ans+1;i++)
            ans+=a[i];
        cout<<ans<<endl;
    }
}
自己选的路,跪着也要把它走完------ACM坑
原文地址:https://www.cnblogs.com/IKnowYou0/p/6632740.html