# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
592956 | stevancv | Robots (IOI13_robots) | C++14 | 1783 ms | 18524 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "robots.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 5e5 + 2;
const int mod = 1e9 + 7;
int putaway(int p, int q, int n, int x[], int y[], int a[], int b[]) {
vector<array<int, 2>> all;
for (int i = 0; i < n; i++) {
all.push_back({a[i], b[i]});
}
for (int i = 0; i < p; i++) x[i]--;
for (int i = 0; i < q; i++) y[i]--;
sort(all.begin(), all.end());
sort(x, x + p);
sort(y, y + q);
auto Can = [&] (int o) {
vector<bool> cov(n);
priority_queue<array<int, 2>> pq;
int j = 0;
for (int i = 0; i < p; i++) {
while (j < n && all[j][0] <= x[i]) {
pq.push({all[j][1], j});
j++;
}
int cnt = 0;
while (!pq.empty() && cnt < o) {
auto w = pq.top();
cov[w[1]] = 1;
pq.pop();
cnt++;
}
}
vector<int> c;
for (int i = 0; i < n; i++) {
if (!cov[i]) c.push_back(all[i][1]);
}
sort(c.begin(), c.end());
j = 0;
for (int i = 0; i < q; i++) {
int cnt = 0;
while (j < c.size() && c[j] <= y[i] && cnt < o) {
j++;
cnt++;
}
}
if (j == c.size()) return true;
return false;
};
int l = 1; int r = n;
int ans = -1;
while (l <= r) {
int mid = l + r >> 1;
if (Can(mid)) {
r = mid - 1;
ans = mid;
}
else l = mid + 1;
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |