求错,在线等

P1478 陶陶摘苹果(升级版)

fzhfzh @ 2019-05-13 18:59:50

#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,s,a,b,cnt=0;
    cin>>n>>s>>a>>b;
    int high[n],liqi[n];
    for(int i=0;i<n;i++){
        cin>>high[i]>>liqi[i]; 
    }
    sort(liqi,liqi+n);
    for(int i=0;;i++){
        if(s<liqi[i])break;
        else if(high[i]<=a+b&&s>=liqi[i]){
            cnt++;
            s-=liqi[i];
        }
    }
    cout<<cnt;
    return 0;
}

by y2823774827y @ 2019-05-13 19:10:58

@封禁用户名f8617dda 这码风怎么了?


by fzhfzh @ 2019-05-13 19:11:35

好的谢谢您 @DARKSTALKING


by ZTL_UwU @ 2019-05-13 19:49:10

@封禁用户名f8617dda 这码风不错呀


上一页 |