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;
// X weight Y size
int a,b,t,X[10000],Y[10000],W[1000000],S[1000000],mxW,mxS , flag = 1;
void count_max() {
for (int i = 0; i < a; i++) mxW = max (mxW,X[i]);
for (int i = 0; i < b; i++) mxS = max (mxS,Y[i]);
for (int i = 0; i < t; i++)
if (W[i] >= mxW && S[i] >= mxS) flag = 0;
}
int case1() {
if (a == 0) {
if (Y[1] > S[1] && Y[0] > S[0]) return 1;
return 2;
}
if (b == 0) {
if (X[1] > W[1] && X[0] > W[0]) return 1;
return 2;
}
if ((X[0] > W[0] && Y[0] > S[1] ) || (X[0] > W[1] && Y[0] > S[0]) )
return 1;
return 0;
}
int case2() {
set < pair<int,int> > s;
int cnt = 0;
for (int i = 0; i < t; i ++) s.insert ({W[i],cnt++});
set<pair<int,int> > g;
vector<int> v;
for (int i = 0; i < a; i++) v.push_back(X[i]);
int timer = 0;
while (!s.empty()) {
timer++;
for (int j = 0,i; j < v.size() && s.size(); j++) {
i = v[j];
auto it = s.lower_bound({i,0});
if (it == s.begin()){
if (j != v.size() - 1)
swap(v[v.size() - 1],v[j]);
v.pop_back();
j--;
}
else {
it--;
s.erase(it);
}
}
}
return timer;
}
int putaway(int A1, int B1, int T1, int X1[], int Y1[], int W1[], int S1[]) {
a = A1; b = B1;t = T1;
for (int i = 0; i < a; i++) X[i] = X1[i];
for (int i = 0; i < b; i++) Y[i] = Y1[i];
for (int i = 0; i < t; i++) W[i] = W1[i], S[i] = S1[i];
sort (X, X + a);
sort (Y, Y + b);
count_max();
if (!flag) return -1;
if (b == 0) return case2();
if (t == 2 && a + b == 2) return case1();
}
Compilation message (stderr)
robots.cpp: In function 'int case2()':
robots.cpp:37:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int j = 0,i; j < v.size() && s.size(); j++) {
~~^~~~~~~~~~
robots.cpp:41:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (j != v.size() - 1)
~~^~~~~~~~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:68:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | 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... |