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;
#define fi first
#define se second
#define sz(x) (int)x.size()
using ii = pair<int,int>;
multiset<ii>ww,ss;
//subtask 1
int putaway(int A,int B,int T, int X[],int Y[],int W[],int S[]){
for(int i=0; i<T; i++){
ww.insert({W[i],S[i]});
ss.insert({S[i],W[i]});
}
sort(X,X+A);
sort(Y,Y+B);
for(int i=0; i<T; i++){
if(W[i]>X[A-1]&&S[i]>Y[B-1])return -1;
}
if(A+B==2&&T==2){
if(A==2){
if((ww.begin()->fi)>X[0])return 2;
else return 1;
}else if(A==1){
if((ww.begin()->se)<=Y[0]&&(ww.rbegin()->fi)<=X[0])return 1;
else if((ww.begin()->fi)<=X[0]&&(ww.rbegin()->se)<=Y[0])return 1;
else return 2;
}else{
if((ss.begin()->fi)>Y[0])return 2;
else return 1;
}
}
return -1;
}
/*
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n,m,t; cin>>n>>m>>t;
int x[n],y[m],w[t],s[t];
for(int i=0; i<n; i++)cin>>x[i];
for(int i=0; i<m; i++)cin>>y[i];
for(int i=0; i<t; i++)
cin>>w[i]>>s[i];
cout<<putaway(n,m,t,x,y,w,s)<<endl;
return 0;
}
// */
//check for -1 both w[i]&s[i] exceed largest x[i]&y[i]
# | 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... |