QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#375551#4089. 회의실SkyanCompile Error//C++231.6kb2024-04-03 12:27:562024-04-03 12:27:56

Judging History

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

  • [2024-04-03 12:27:56]
  • 评测
  • [2024-04-03 12:27:56]
  • 提交

answer

#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
map<int, int> m;
long long int z = 0, f[5005];
vector<pair<int, int>> g[5005], gg[5005];
long long int min_charge(int k, vector<int> s, vector<int> e, vector<int> w) {
    vector<int> v;
    for (int w : s) v.push_back(w);
    for (int w : e) v.push_back(w + 1);
    sort(v.begin(), v.end());
    for (int w : v) {
        if (!m.count(w)) {
            m[w] = ++z;
        }
    }
    int n = s.size();
    for (int i = 0; i < n; i++) {
        s[i] = m[s[i]];
        e[i] = m[e[i] + 1] - 1;
        g[s[i]].push_back({e[i], w[i]});
        gg[e[i]].push_back({s[i], w[i]});
    }
    for (int i = 1; i <= z; i++) {
        priority_queue<long long int> q;
        f[i] = 1e18;
        long long int c = 0;
        for (int j = i; j >= 1; j--) {
            for (auto w : gg[j]) {
                c += w.second;
            }
            for (auto w : g[j]) {
                if (w.first <= i) {
                    c -= w.second;
                    q.push(-w.second);
                    while (q.size() > k) {
                        c -= q.top();
                        q.pop();
                    }
                }
            }
            f[i] = min(f[i], f[j - 1] + c);
        }
    }
    return f[z];
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int N,K;cin >> N >> K;
    vector<int> S(N),E(N),W(N);
    for(int i=0;i<N;i++) cin >> S[i] >> E[i] >> W[i];
    cout << min_charge(K,S,E,W) << '\n';
}

Details

/usr/bin/ld: /tmp/ccMfmVYw.o: in function `main':
answer.code:(.text.startup+0x0): multiple definition of `main'; /tmp/cc7mP7Kw.o:implementer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status