Submission #127105

# Submission time Handle Problem Language Result Execution time Memory
127105 2019-07-08T22:27:57 Z eriksuenderhauf Hotel (CEOI11_hot) C++11
100 / 100
1286 ms 54488 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%I64d", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
int c[MAXN], p[MAXN];
multiset<pii> st;
vii a;
vi ans;

int main()
{
    int n, m, o;
    ni(n), ni(m), ni(o);
    for (int i = 0; i < n; i++)
    {
        ni(c[i]), ni(p[i]);
        st.insert({p[i], c[i]});
    }
    for (int i = 0; i < m; i++)
    {
        int v, d;
        ni(v), ni(d);
        a.pb({v, -d});
    }
    sort(a.rbegin(), a.rend());
    for (int i = 0; i < m; i++)
    {
        auto it = st.lower_bound({-a[i].se, -INF});
        if (it == st.end())
            continue;
        if (a[i].fi < it->se)
            continue;
        st.erase(it);
        ans.pb(a[i].fi - it->se);
    }
    sort(ans.rbegin(), ans.rend());
    ll res = 0;
    for (int i = 0; i < min(o, (int) ans.size()); i++)
        res += (ll) ans[i];
    prl(res);
    return 0;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     ni(n), ni(m), ni(o);
                 ^
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:38:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:41:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ni(c[i]), ni(p[i]);
                 ^
hot.cpp:41:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
hot.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         ni(v), ni(d);
              ^
hot.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
# Verdict Execution time Memory Grader output
1 Correct 2 ms 508 KB Output is 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 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 352 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 13 ms 1400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 65 ms 4724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 119 ms 8052 KB Output is correct
2 Correct 91 ms 6528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 406 ms 22420 KB Output is correct
2 Correct 187 ms 11480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 892 ms 43940 KB Output is correct
2 Correct 945 ms 41060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1028 ms 51612 KB Output is correct
2 Correct 1195 ms 54488 KB Output is correct
3 Correct 1286 ms 52264 KB Output is correct