20分求助!!
  • 板块灌水区
  • 楼主WanKey
  • 当前回复3
  • 已保存回复3
  • 发布时间2021/12/6 22:28
  • 上次更新2023/11/3 22:45:50
查看原帖
20分求助!!
529797
WanKey楼主2021/12/6 22:28

P1478

#include<bits/stdc++.h>
using namespace std;
struct apple{
    int high;
    int l;
};
bool cmp(apple a,apple b){
    return a.l<b.l;
}
int main(){
    apple applec[100000];
    int a,s,c,b,sum=0,tmp=0;
    cin>>a>>s>>c>>b;
    b+=c;
    sum=b;
    for(int i=0;i<=a-1;i++){
        cin>>applec[i].high;
        cin>>applec[i].l; 
    }
    sort(applec,applec+a,cmp);
    for(int i=0;i<a;++i){
        if(applec[i].l<=s&&applec[i].high<=b){
            sum-applec[i].l;
            tmp++;
        }
    }
    cout<<tmp;
}
2021/12/6 22:28
加载中...