Submission #132598

# Submission time Handle Problem Language Result Execution time Memory
132598 2019-07-19T08:07:02 Z Vardanyan Hotel (CEOI11_hot) C++14
20 / 100
4000 ms 55756 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 500*1000+5;
long long c[N],p[N];
long long v[N],d[N];
bool cmp(pair<long long, long long> a, pair<long long,long> b){
    if(a.first>b.first) return a.first>b.first;
    if(a.first<b.first) return a.first>b.first;
    return a.second<b.second;
}
int main(){
    ios_base::sync_with_stdio(false);
    int n,m,k;
    cin>>n>>m>>k;
    multiset<pair<long long,long long> > ms;
    for(int i = 1;i<=n;i++){
        cin>>c[i]>>p[i];
        ms.insert({c[i],p[i]});
    }
    vector<pair<long long,long long> > all;
    for(int i = 1;i<=m;i++){
        cin>>v[i]>>d[i];
        all.push_back({v[i],d[i]});
    }
    sort(all.begin(),all.end(),cmp);
    int qn = k;
    long long ans = 0;
    for(int i = 0;i<all.size();i++){
        if(!qn) break;
        long long x = all[i].second;
    //    if(ms.lower_bound({x,0}) == ms.end()) continue;
    //    pair<long long,long long> u = *ms.lower_bound({0,x});
        multiset<pair<long long,long long> >::iterator it = ms.begin();
        for(;it!=ms.end();it++){
            pair<long long,long long> u = *it;
            if(u.second>=x) break;
        }
        pair<long long,long long> u = *it;
        if(u.second>=x){
          if(all[i].first-u.first>0){
                ans-=u.first;
                ans+=all[i].first;
                ms.erase(ms.find(u));
                qn--;
          }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:28:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0;i<all.size();i++){
                   ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 133 ms 1912 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4096 ms 5492 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Execution timed out 4033 ms 9508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4098 ms 22840 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4091 ms 44756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4025 ms 55756 KB Time limit exceeded
2 Halted 0 ms 0 KB -