0分求助
查看原帖
0分求助
1191398
keep_eating楼主2024/7/9 14:28
#include <bits/stdc++.h>

using namespace std;

#define endl '\n'

#define TRACE 1
#define tcout TRACE && cout

#define fst ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define int unsigned long long
#define re register
#define inl inline
const int P = 998244353;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e6 + 10, M = 2e3 + 10;
struct Node{
	int t1,t2;
}a[N];
inl bool cmp(Node x,Node y){
	return x.t2<y.t2;
}
int num;
signed main(){
	fst
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i].t1>>a[i].t2;
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++){
		num+=a[i].t1;
		if(num>=a[i].t2){
			cout<<i;
			return 0;
		}
	}
	return 0;
}

2024/7/9 14:28
加载中...