题目太水
查看原帖
题目太水
1328532
Tmc2012楼主2024/10/25 16:34

这题也太水了,我还以为很难

#include <bits/stdc++.h>
using namespace std;
#define LL long long 
const int N=1e6+10;
struct node{
    int x,y;
}apple[N];
int n,s,a,b,ans;
bool cmp(node a,node b){
    return a.y<b.y;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin>>n>>s>>a>>b;
    for(int i=1;i<=n;i++) cin>>apple[i].x>>apple[i].y;
    sort(apple+1,apple+1+n,cmp);
    for(int i=1;i<=n;i++){
        if(a+b>=apple[i].x&&s>=apple[i].y){
            s-=apple[i].y;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

就这个代码,本蒟蒻居然一遍写对???

2024/10/25 16:34
加载中...