QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#370338#4089. 회의실seojinhyeong990 0ms0kbC++171.9kb2024-03-29 02:10:302024-03-29 02:10:32

Judging History

你现在查看的是最新测评结果

  • [2024-03-29 02:10:32]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-03-29 02:10:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
typedef pair<int, int> pi;
typedef long long ll;
long long int min_charge(int K, vector<int> S, vector<int>E, vector<int>W) {
    int n, k;
    n = S.size();
    k = K;
    vector<array<ll, 3>>v(n);
    for (int i = 0; i < n; i++) {
        v[i] = { S[i],E[i],W[i] };
    }
    sort(v.begin(), v.end());
    vector<priority_queue<ll, vector<ll>, greater<ll>>>pq(n);
    vector<ll>d(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (v[i][1] >= v[j][1]) {
                pq[i].push(v[j][2]);
                d[i] += v[j][2];
                if (pq[i].size() > k) {
                    d[i] -= pq[i].top();
                    pq[i].pop();
                }
            }
        }
    }
    vector<int>a(n);
    for (int i = 0; i < n; i++) a[i] = i;
    for (int i = 0; i < n; i++) {
        auto& cur = v[i];
        sum += cur[2];
        int e = i - 1;
        multiset<ll, greater<ll>>s;
        s.insert(0);
        for (int j = 0; j < i; j++) s.insert(d[j]);
        ll mx = d[i];
        for (int j = i; j >= 0; j--) {
            if (v[j][1] < cur[0]) break;
            if (v[j][1] > v[i][1]) continue;
            while (e >= 0 && v[a[e]][1] >= v[j][0]) {
                auto it = s.find(d[e--]);
                s.erase(it);
            }
            ll base = *s.begin();
            pq[i].push(v[j][2]);
            d[i] += v[j][2];
            if (pq[i].size() > k) {
                d[i] -= pq[i].top();
                pq[i].pop();
            }
            mx = max(mx, d[i] + base);
        }
        d[i] = mx;
        sort(a.begin(), a.begin() + i, [&](int x, int y)->bool {
            return v[x][1] < v[y][1];
            });
        //cout<<i<<" : "<<mx<<"\n";
    }
    ll ans = 0;
    for (auto i : d) ans = max(ans, i);
    cout << sum - ans;
}

详细

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

5 1
2 6 5
4 6 2
8 8 5
1 3 4
6 8 7

output:

Unauthorized output

result:


Subtask #2:

score: 0
Runtime Error

Test #64:

score: 0
Runtime Error

input:

248 1
798307257 798307257 359993686
798307257 798307257 812363141
798307257 798307257 872983330
798307257 798307257 537223276
798307257 798307257 375626816
798307257 798307257 518196362
798307257 798307257 474572280
798307257 798307257 277617903
798307257 798307257 473712578
798307257 798307257 5366...

output:

Unauthorized output

result:


Subtask #3:

score: 0
Runtime Error

Test #88:

score: 0
Runtime Error

input:

248 135
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992812 806992812 1
806992...

output:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%