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>
using namespace std;
using ll = long long;
#define all(x) x.begin(), x.end()
#define mp make_pair
#define mt make_tuple
#define x first
#define y second
#include "robots.h"
const int N = 5e4 + 10;
bool used[N];
void iter(int a, int b, int t, int x[], int y[], int w[], int s[]) {
// cout << "iter " << a << " " << b << " " << t << endl;
for (int i = 0; i < a; ++i) {
int mx = -1;
for (int j = 0; j < t; ++j) {
if (used[j] || w[j] > x[i]) {
continue;
}
if (mx == -1 || s[mx] < s[j]) {
mx = j;
}
}
if (mx != -1) {
// cout << "take w " << w[i] << ": " << x[mx] << " " << y[mx] << endl;
used[mx] = true;
}
}
for (int i = 0; i < b; ++i) {
int mx = -1;
for (int j = 0; j < t; ++j) {
if (used[j] || s[j] > y[i]) {
continue;
}
if (mx == -1 || w[mx] < w[j]) {
mx = j;
}
}
if (mx != -1) {
// cout << "take s " << s[i] << ": " << x[mx] << " " << y[mx] << " @" << mx << endl;
used[mx] = true;
}
}
}
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
sort(x, x + a);
sort(y, y + b);
int ti = 0;
while (1) {
int was = (int)count(used, used + t, true);
if (was == t) {
break;
}
++ti;
iter(a, b, t, x, y, w, s);
int now = (int)count(used, used + t, true);
if (was == now) {
return -1;
}
}
return ti;
}
#ifdef LC
#include "grader.c"
#endif
# | 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... |