Submission #467443

#TimeUsernameProblemLanguageResultExecution timeMemory
467443SirCovidThe19thRobots (IOI13_robots)C++17
0 / 100
1 ms224 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(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; //return (high == T + 1) ? -1 : high; }
#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...