제출 #467444

#제출 시각아이디문제언어결과실행 시간메모리
467444SirCovidThe19th로봇 (IOI13_robots)C++17
100 / 100
1900 ms24352 KiB
#include <bits/stdc++.h>
#include "robots.h"
using namespace std; 

int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
    pair<int, int> toys[T];
    for (int i = 0; i < T; i++) toys[i] = {W[i], S[i]};
    sort(X, X + A); sort(Y, Y + B); sort(toys, toys + T); 

    auto check = [&](int mid){
        priority_queue<int> pq; int pt = 0;
        for (int i = 0; i < A; i++){
            for (; pt < T and toys[pt].first < X[i]; pt++) pq.push(toys[pt].second);
            for (int j = 0; j < mid and !pq.empty(); j++) pq.pop();
        }
        for (; pt < T; pt++) pq.push(toys[pt].second);
        for (int i = B - 1; i >= 0; i--){
            for (int j = 0; j < mid and !pq.empty() and pq.top() < Y[i]; j++) pq.pop();
        }
        return pq.empty();
    };
    
    int low = 1, high = T;
    while (low < high){
        int mid = (low + high) / 2;
        check(mid) ? high = mid : low = mid + 1;
    }
    return check(high) ? high : -1;
}
#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...