답안 #227728

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
227728 2020-04-28T15:18:25 Z dolphingarlic Hotel (CEOI11_hot) C++14
100 / 100
1396 ms 62956 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

pair<ll, int> orders[500000];
multiset<pair<int, ll>> rooms;
priority_queue<ll> res;

int main() {
    int n, m, o;
    scanf("%d %d %d", &n, &m, &o);
    for (int i = 0; i < n; i++) {
        ll cost;
        int sz;
        scanf("%lld %d", &cost, &sz);
        rooms.insert({sz, cost});
    }
    for (int i = 0; i < m; i++) scanf("%lld %d", &orders[i].first, &orders[i].second);
    sort(orders, orders + m, greater<pair<ll, int>>());
    for (int i = 0; i < m; i++) {
        auto ptr = rooms.lower_bound({orders[i].second, LLONG_MIN});
        if (ptr == rooms.end()) continue;
        res.push(orders[i].first - (*ptr).second);
        rooms.erase(ptr);
    }

    ll ans = 0;
    for (int i = 0; i < o; i++) {
        if (!res.size() || res.top() < 0) break;
        ans += res.top();
        res.pop();
    }
    printf("%lld\n", ans);
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:11: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:15:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %d", &cost, &sz);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
hot.cpp:18:38: 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("%lld %d", &orders[i].first, &orders[i].second);
                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 1152 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 4084 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 112 ms 7000 KB Output is correct
2 Correct 85 ms 7668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 393 ms 18284 KB Output is correct
2 Correct 169 ms 14064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 863 ms 36044 KB Output is correct
2 Correct 1044 ms 51456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1002 ms 43748 KB Output is correct
2 Correct 1214 ms 62956 KB Output is correct
3 Correct 1396 ms 60140 KB Output is correct