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"
using namespace std;
typedef long long ll;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<pair<int,int>> toys;
for (int i=0; i<T; i++) {
toys.push_back({W[i],S[i]});
}
sort(X,X+A);
sort(Y,Y+B);
sort(toys.begin(),toys.end());
int ans=0;
vector<int> done(T, 0);
bool pos=true;
while (true) {
int no_done=0;
bool is_all=true;
for (int j=0; j<A; j++) {
int x=X[j];
int tind=-1;
int ts=-1;
for (int i=0; i<T; i++) {
if (done[i]) continue;
is_all=false;
if (W[i]<x) {
if (S[i]>ts||(S[i]==ts&&W[i]>=W[tind])) {
ts=S[i];
tind=i;
}
}
}
if (tind!=-1) {
no_done++;
done[tind]=1;
}
}
for (int j=0; j<B; j++) {
int y=Y[j];
int tind=-1;
int tw=-1;
for (int i=0; i<T; i++) {
if (done[i]) continue;
is_all=false;
if (S[i]<y) {
if (W[i]>=tw||(W[i]==tw&&S[i]>=S[tind])) {
tw=W[i];
tind=i;
}
}
}
if (tind!=-1) {
no_done++;
done[tind]=1;
}
}
ans++;
if (no_done==0&&!is_all) {
pos=false;
break;
} else if (no_done==0&&is_all) {
ans--;
break;
}
}
if (pos) return ans;
return -1;
}
# | 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... |