求助莫名编译错误
查看原帖
求助莫名编译错误
231800
Veranda楼主2022/7/15 22:15
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>

using namespace std;

const int N = 150010;

struct Node{
    int t1,t2;
};
int n;
Node a[N];
priority_queue<Node> q;

bool cmp(Node a,Node b){
	bool f = a.t2 < b.t2;
    return f;
}

int main(){
    cin >> n;
    for(int i = 1;i <= n;i ++){
        cin >> a[i].t1 >> a[i].t2;
    }
    
    sort(a + 1,a + 1 + n,cmp);
    
    int s = 0;
    for(int i = 1;i <= n;i ++){
        if(a[i].t1 + s > a[i].t2){
            if(a[i].t1 < q.top().t1){
                s -= q.top().t1;
                q.pop();
                q.push(a[i]);
                s += a[i].t1;
            }
        }
        else{
            s += a[i].t1;
            q.push(a[i]);
        }
    }
    
    cout << q.size();
}

非常奇怪

2022/7/15 22:15
加载中...