彩虹测试点求救!!!样例都过了

P1478 陶陶摘苹果(升级版)

dongrq_cs @ 2023-04-18 20:49:59

#include <iostream>
using namespace std;
int main(){
    int x[300] = {},y[110] = {},n,s,a,b,ans = 0;
    cin >> n >> s >> a >> b;
    for(int i = 1;i <= n;i++){
        cin >> x[i] >> y[i];
    }
    b += a;
    for(int i = 1;i <= n;i++){
        if(b >= x[i] && s >= y[i]){
            ans++;
            s--;
        }
    }
    cout << ans;
    return 0;
}


by Ice_lift @ 2023-04-18 21:34:01

@dongrq_cs 这题似乎不是模拟


by Ice_lift @ 2023-04-18 21:41:19

#include<bits/stdc++.h>
using namespace std;
int n,s,a,b,ans;
int x,y,p[5005],cnt;
int main(){
    cin>>n>>s>>a>>b;
    b+=a;
    for(int i=1;i<=n;i++){
        cin>>x>>y;
        if(x<=b){
            p[++cnt]=y;//可以摘到的苹果
        }
    }
    sort(p+1,p+1+cnt);//从小到大排序
    for(int i=1;i<=cnt;i++){
        if(s>=p[i]){
            ans++;
            s-=p[i];
        }
    }
    cout<<ans;
    return 0;
}

@dongrq_cs


by dongrq_cs @ 2023-04-20 21:27:35

@qym__xiaobai 谢! 抱歉才看到


by hkr1469 @ 2023-05-28 16:40:38

?


|