请求加强数据
查看原帖
请求加强数据
482998
jeffstart楼主2023/11/22 15:34

我的代码:

#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

struct edge {
    mutable int a, b, c;
    bool operator<(const edge &t) const {
        if (a == t.a) {
            return b > t.b;
        }
        return a > t.a;
    }
} w[N];

int comp(edge a, edge b) { return a.b < b.b; }

int main() {
    priority_queue<edge> que;
    int x, n;
    cin >> x >> n;
    for (int i = 1; i <= n; i++) {
        cin >> w[i].a >> w[i].b >> w[i].c;
    }
    sort(w + 1, w + n + 1, comp);
    int top = n, ans = 0;
    for (int i = x; i; i--) {
        while (w[top].b >= i) {
            que.push(w[top]);
            top--;
        }
        ans += que.top().a;
        que.top().c--;
        if (!que.top().c) {
            que.pop();
        }
    }
    cout << ans << "\n";
    return 0;
}

没有使用 long long 就 AC 了,请求加强数据。

@小粉兔 @StudyingFather

我不知道谁是题目管理员(懒得看了),于是就随便 @ 了两个,好心的同学可以帮我 @ 一下题目管理员,谢谢。

2023/11/22 15:34
加载中...