Submission #115551

# Submission time Handle Problem Language Result Execution time Memory
115551 2019-06-08T06:48:24 Z gs14004 Hotel (CEOI11_hot) C++17
100 / 100
1570 ms 54628 KB
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef multiset<pi> ::iterator aauto;

int n, m, o;

multiset<pi> s;

int c[500005], p[500005];
vector<pi> v, q;
vector<int> match;

int main(){
    scanf("%d %d %d",&n,&m,&o);
    for(int i=0; i<n; i++){
        scanf("%d %d",&c[i],&p[i]);
        s.insert(pi(p[i], c[i]));
    }
    for(int i=0; i<m; i++){
        int val, d;
        scanf("%d %d",&val, &d);
        q.push_back(pi(val, -d));
    }
    sort(q.begin(), q.end());
    reverse(q.begin(), q.end());
    for(int i=0; i<q.size(); i++){
        aauto t = s.lower_bound(pi(-q[i].second, -1e9));
        if(t == s.end()) continue;
        int diff = q[i].first - t->second;
        if(diff < 0) continue;
        s.erase(t);
        match.push_back(diff);
    }
    sort(match.begin(), match.end());
    reverse(match.begin(), match.end());
    long long ret = 0;
    for(int i=0; i<o && i < match.size(); i++){
        ret += max(match[i], 0);
    }
    printf("%lld\n",ret);
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:30:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<q.size(); i++){
                  ~^~~~~~~~~
hot.cpp:41:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0; i<o && i < match.size(); i++){
                         ~~^~~~~~~~~~~~~~
hot.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d %d",&n,&m,&o);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~
hot.cpp:20:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&c[i],&p[i]);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~
hot.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d",&val, &d);
         ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 4724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 126 ms 8004 KB Output is correct
2 Correct 97 ms 6600 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 383 ms 22172 KB Output is correct
2 Correct 159 ms 11672 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 874 ms 44024 KB Output is correct
2 Correct 1049 ms 41212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1063 ms 51568 KB Output is correct
2 Correct 1260 ms 54628 KB Output is correct
3 Correct 1570 ms 52052 KB Output is correct