Submission #217571

#TimeUsernameProblemLanguageResultExecution timeMemory
217571DystoriaXCloud Computing (CEOI18_clo)C++14
0 / 100
7 ms640 KiB
#include <bits/stdc++.h>

using namespace std;

struct node{
    int c, f, v;
};

int n, m;
vector<node> comp, dem;
priority_queue<int, vector<int>, greater<int> > pq;
long long ans = 0;

bool cp(node a, node b){
    return a.f > b.f;
}

int main(){
    scanf("%d", &n);

    comp.resize(n);
    for(int i = 0; i < n; i++) scanf("%d%d%d", &comp[i].c, &comp[i].f, &comp[i].v);

    scanf("%d", &m);

    dem.resize(m);
    for(int i = 0; i < m; i++) scanf("%d%d%d", &dem[i].c, &dem[i].f, &dem[i].v);
    

    sort(comp.begin(), comp.end(), cp);
    sort(dem.begin(), dem.end(), cp);

    int idx = 0;

    for(auto k : dem){
        while(idx < n && comp[idx].f >= k.f) pq.push(comp[idx++].v);

        if(k.v - pq.top() > 0){
            // cout << k.v << " " << pq.top() << endl;
            ans += k.v - pq.top(); pq.pop();
        }
    }

    printf("%lld\n", ans);

    return 0;
}

Compilation message (stderr)

clo.cpp: In function 'int main()':
clo.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
clo.cpp:22:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < n; i++) scanf("%d%d%d", &comp[i].c, &comp[i].f, &comp[i].v);
                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &m);
     ~~~~~^~~~~~~~~~
clo.cpp:27:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i = 0; i < m; i++) scanf("%d%d%d", &dem[i].c, &dem[i].f, &dem[i].v);
                                ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...