#include<bits/stdc++.h>
using namespace std;
struct building{
int fixed,broken;
bool operator<(const building& p){
return (broken-fixed)<(p.broken-p.fixed);
}
};
int main(){
long long total=0;
int n;
cin>>n;
building build[n];
for(int i=0;i<n;i++){
cin>>build[i].fixed>>build[i].broken;
}
priority_queue<int> time;
sort(build,build+n);
for(int i=0;i<n;i++){
if(build[i].broken-total-build[i].fixed<=0){
if(time.size()==0) continue;
else{
if(build[i].fixed<time.top()){
total-=time.top();
time.pop();
}else{
continue;
}
}
}
total+=build[i].fixed;
time.push(build[i].fixed);
}
cout<<time.size();
}
代码如上。自己改了几次依然有一个数据是WA,请问是哪里出了问题?