제출 #597702

#제출 시각아이디문제언어결과실행 시간메모리
597702snasibov05로봇 (IOI13_robots)C++14
100 / 100
1563 ms24404 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) { int ans = -1; sort(x, x + a); sort(y, y + b); reverse(y, y + b); vector<pair<int, int>> v; for (int i = 0; i < t; ++i) v.push_back({w[i], s[i]}); sort(v.begin(), v.end()); int l = 1, r = t; while (l <= r){ int mid = (l + r) / 2; int pt = 0; priority_queue<int> pq; for (int i = 0; i < a; ++i){ while (pt < t && v[pt].first < x[i]) pq.push(v[pt++].second); for (int j = 0; j < mid; ++j){ if (pq.empty()) break; pq.pop(); } } while (pt < t) pq.push(v[pt++].second); for (int i = 0; i < b; ++i){ for (int j = 0; j < mid; ++j){ if (pq.empty() || pq.top() >= y[i]) break; //cerr << pq.top() << "\n"; pq.pop(); } } if (pq.empty()) ans = mid, r = mid - 1; else l = mid + 1; } return ans; }
#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...