1 solutions

  • 0
    @ 2025-8-26 20:36:45
    #include<bits/stdc++.h>
    using namespace std;
    const int N=2e5+10;
    typedef long long LL;
    struct Stu{
    	LL id;
    	int money;
    };
    bool cmp(Stu a,Stu b)
    {
    	if(a.id<b.id) return 1;
    	return 0;
    }
    Stu stu[N];
    int main()
    {
      	int n;
      	LL k;
      	cin>>n>>k;
      	for(int i=1;i<=n;i++)
      	{
      		cin>>stu[i].id>>stu[i].money;	
    	}
    	sort(stu+1,stu+n+1,cmp);
    	for(int i=1;i<=n;i++)
    	{
    		if(k<stu[i].id) break;
    		k+=stu[i].money;
    	}
    	cout<<k;
        return 0;
    }
    
    • 1

    [ABC203C] 朋友和旅行费用(Friends and Travel costs)

    Information

    ID
    2618
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    1
    Tags
    # Submissions
    10
    Accepted
    2
    Uploaded By