Submission #482091

# Submission time Handle Problem Language Result Execution time Memory
482091 2021-10-23T04:11:59 Z Neos Hotel (CEOI11_hot) C++14
10 / 100
600 ms 86220 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define task "test"
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- )
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define ar array
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 5e5 + 7;
const ll inf = 0x3f3f3f3f;

int n, m, k, res;
ii c[N];
set<ar<int, 3>> rooms;

bool operator<(ar<int, 3> a, ar<int, 3> b) {
    return a[0] < b[0];
}

int main() {
    fastIO;

    cin >> n >> m >> k;
    forw(i, 0, n) {
        ar<int, 3> room;
        cin >> room[1] >> room[0], room[2] = i;
        rooms.insert(room);
    }
    forw(i, 0, m) cin >> c[i].fi >> c[i].se;
    sort(c, c + m, greater<ii>());

    vi profit;
    forw(i, 0, m) {
        auto it = rooms.lower_bound({c[i].se, 0, 0});
        int cur = c[i].fi - (*it)[1];
        if (cur > 0) {
            profit.pb(cur);
            rooms.erase(it);
        }
    }
    sort(all(profit), greater<int>());
    forw(i, 0, min(k, sz(profit))) res += profit[i];
    cout << res;
}

Compilation message

hot.cpp: In function 'int main()':
hot.cpp:24:12: warning: narrowing conversion of 'c[i].std::pair<long long int, long long int>::second' from 'long long int' to 'int' [-Wnarrowing]
   24 | #define se second
      |            ^
hot.cpp:59:43: note: in expansion of macro 'se'
   59 |         auto it = rooms.lower_bound({c[i].se, 0, 0});
      |                                           ^~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 8 ms 1944 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 39 ms 6760 KB Execution killed with signal 6
# Verdict Execution time Memory Grader output
1 Runtime error 69 ms 11540 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 198 ms 33840 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 469 ms 69536 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 600 ms 86220 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -