40分

P1478 陶陶摘苹果(升级版)

abc_abc_abc @ 2024-03-31 09:37:09

#include <bits/stdc++.h>
using namespace std;
long long ans,n,s,a,b,min;
bool cmp(int x,int y)
{
    return x < y;
}
struct
{
    long long g;
    long long l;
} arr[1000010];
int main()
{
    cin >> n >> s >> a >> b;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i].g >> arr[i].l;
    }
    sort(arr,arr + n,cmp);
    for (int i = 0; i < n; i++)
    {
        if (arr[i].g <= a + b)
        {
            if (s - arr[i].l > 0)
            {
                s -= arr[i].l;
                ans++;
            }
            else
            {
                break;
            }
        }
    }
    cout << ans;
    return 0;
}

by abc_abc_abc @ 2024-03-31 09:37:54

帮我一下呗


by shenhan2023 @ 2024-03-31 09:40:46

666


by __little__Cabbage__ @ 2024-03-31 10:15:25

请详细告诉我是WA还是RE


by abc_abc_abc @ 2024-04-15 21:48:17

@littleCabbage__ 好好搞行不


|