compile error 为什么?本地可以过,求解

P1478 陶陶摘苹果(升级版)

fghfghfgh @ 2018-07-07 13:01:17

#include<bits/stdc++.h>
using namespace std;
struct gg{
    int high,s;
}a[1000];
int main()
{
    int b,c,d,e,f=0,g=0,h=0,sum=0,counts=0;
    cin>>b>>c>>d>>e;
    h=d+e;
    for(int i=0;i<b;i++){
        cin>>f>>g;
        if(f<=h){
            a[counts].high=f;
            a[counts++].s=g;
        }
    }
    sort(a,a+counts,[](gg a,gg b){return a.s< b.s;});
    for(sum=0;sum<counts;sum++){
        c=c-a[sum].s;
        if(c<0)
            break;
    }
    printf("%d",sum);
    return 0;
}

by info___tion @ 2018-07-07 13:08:09

把sort的比较函数写在外面


by SeKong @ 2018-07-07 13:14:19

lambda开C++11


|