我自己debug了一晚上,结果还是WA 30pt。特地向各位大佬请求支援。为呈上本薛弱的代码
#include<bits/stdc++.h>
#define cin(x) scanf("%d",&x)
using namespace std;
#define int long long
const int X = 1e5+10;
struct node {
int t1,t2;
} ans;
bool operator < (const node &a,const node &b) {
return a.t2>b.t2;
}
priority_queue<node> q;
int n,m,k,sum;
int a[X],b[X],c[X],now;
signed main() {
scanf("%d",&n);
for(int i = 1; i<=n; i++) {
cin(ans.t1);
cin(ans.t2);
q.push(ans);
}
for(int i = 1; i<=n; i++) {
ans = q.top();
q.pop();
if(now+ans.t1<=ans.t2) {
now+=ans.t1;
sum++;
}
}
cout << sum;
return 0;
}
请求支援。
代码不容易,请不要乱回答。