Submission #732985

# Submission time Handle Problem Language Result Execution time Memory
732985 2023-04-30T00:49:53 Z 1bin Hotel (CEOI11_hot) C++14
100 / 100
1162 ms 62996 KB
#include <bits/stdc++.h>

using namespace std;

#define all(v) v.begin(), v.end()
typedef long long ll;
ll n, m, o, a, b, ans;
multiset<pair<ll, ll>> s;
vector<ll> arr;

int main(void){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    cin >> n >> m >> o;
    vector<pair<ll, ll>> O(m);
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        s.emplace(b, a);
    }
    for(auto&t : O) cin >> t.first >> t.second;
    sort(all(O)); reverse(all(O));
    
    for(auto&[v, d] : O){
        auto it = s.lower_bound({d, 0});
        if(it == s.end()) continue;
        a = v - it->second;
        s.erase(it);
        if(a > 0) arr.emplace_back(a);
    }
    sort(all(arr)); reverse(all(arr));
    for(int i = 0; i < min(o, (ll) arr.size()); i++) ans += arr[i];
    cout << ans;
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:23:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |     for(auto&[v, d] : O){
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 40 ms 3836 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 72 ms 6316 KB Output is correct
2 Correct 56 ms 7312 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 290 ms 18104 KB Output is correct
2 Correct 121 ms 13952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 674 ms 35756 KB Output is correct
2 Correct 724 ms 46996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 798 ms 43612 KB Output is correct
2 Correct 878 ms 62996 KB Output is correct
3 Correct 1162 ms 60052 KB Output is correct