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 "robots.h"
#include <bits/stdc++.h>
//#include "grader.cpp"
using namespace std;
const int N=1e6+5;
const int N1=5e4+5;
multiset< pair<int, int> >wt,st;
vector< pair<int,int> >r;
int solve(){
int ans=0;
while(true){
ans++;
for(auto x:r){
if(wt.size() == 0) break;
int robot=x.first;
int type=x.second;
if(type == 0)
{
auto toy =wt.upper_bound({robot,0});
if(toy == wt.begin()) continue;
toy--;
int wtoy = (*toy).first;
int stoy = (*toy).second;
wt.erase( wt.find( {wtoy,stoy} ) );
st.erase( st.find( {stoy,wtoy} ) );
}
if(type == 1)
{
auto toy=st.upper_bound({robot,0});
if(toy == st.begin()) continue;
toy--;
int wtoy = (*toy).first;
int stoy = (*toy).second;
wt.erase( wt.find( {wtoy,stoy} ) );
st.erase( st.find( {stoy,wtoy} ) );
}
cout<<robot<<"\n";
}
if(wt.size() == 0) break;
}
return ans;
}
int putaway(int a, int b, int t, int a1[], int b1[], int w[], int s[]) {
for(int i=0;i<t;i++){
if(a&&b){
if(w[i]>=a1[a-1]&&s[i]>=b1[b-1]) return -1;
}else if(a){
if(w[i]>=a1[a-1]) return -1;
}else
if(s[i]>=b1[b-1]) return -1;
wt.insert({w[i],s[i]});
st.insert({s[i],w[i]});
}
for(int i=0;i<a;i++) r.push_back({a1[i],0});
for(int i=0;i<b;i++) r.push_back({b1[i],1});
sort(r.rbegin(),r.rend());
int ans=solve();
return ans;
}
/*
*/
# | 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... |