제출 #511459

#제출 시각아이디문제언어결과실행 시간메모리
511459tabrRobots (IOI13_robots)C++17
100 / 100
592 ms24352 KiB
#include <bits/stdc++.h>
using namespace std;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

#ifndef tabr
#include "robots.h"
#endif

int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
    sort(x, x + a);
    sort(y, y + b);
    vector<pair<int, int>> z;
    for (int i = 0; i < t; i++) {
        if (w[i] >= x[a - 1] && s[i] >= y[b - 1]) {
            return -1;
        }
        int z1 = (int) (x + a - upper_bound(x, x + a, w[i]));
        int z2 = (int) (y + b - upper_bound(y, y + b, s[i]));
        z.emplace_back(z1, z2);
    }
    sort(z.begin(), z.end());
    int low = 0;
    int high = t;
    while (high - low > 1) {
        int mid = (high + low) / 2;
        vector<int> c;
        priority_queue<int> pq;
        for (int i = 0; i < t; i++) {
            pq.emplace(z[i].second);
            if ((int) pq.size() > mid * 1LL * z[i].first) {
                c.emplace_back(pq.top());
                pq.pop();
            }
        }
        sort(c.begin(), c.end());
        int ok = 1;
        int cnt = 0;
        for (int i : c) {
            cnt++;
            if (cnt > mid * 1LL * i) {
                ok = 0;
                break;
            }
        }
        if (ok) {
            high = mid;
        } else {
            low = mid;
        }
    }
    return high;
}

#ifdef tabr
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, t, x[100], y[100], w[100], s[100];
    cin >> a >> b >> t;
    for (int i = 0; i < a; i++) {
        cin >> x[i];
    }
    for (int i = 0; i < b; i++) {
        cin >> y[i];
    }
    for (int i = 0; i < t; i++) {
        cin >> w[i] >> s[i];
    }
    cout << putaway(a, b, t, x, y, w, s) << '\n';
    return 0;
}
#endif
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...