# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1002533 | hasan2006 | Robots (IOI13_robots) | C++17 | 0 ms | 0 KiB |
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 TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"
int putaway(int A, int B, int T, vector<int>X, vector<int>Y, vector<int>W, vector<int>S) {
ll i , j , l ,r , s = 0 , f , x , y , k , n, m , ans = 0;
sort(all(X));
sort(all(Y));
vector<pair<int,int>>v;
for(i = 0; i < T; i++){
v.pb({W[i] , S[i]});
if(A > 0 && X[A - 1] > W[i])
continue;
if(B > 0 && Y[B - 1] > S[i])
continue;
return -1;
}
sort(all(v));
l = 1;
r = T;
while(l != r){
m = (l + r) / 2;
ll R = 0;
multiset<pair<int,int>>st;
for(i = 0; i < A; i++){
while(R < v.size() && v[R].fi < X[i])
st.insert({v[R].se , v[R].fi}),R++;
y = m;
while((y--) && st.size()){
st.erase(st.find({st.rbegin()->fi , st.rbegin()->se}));
}
}
if(m == 1)
cout<<st.size()<<"\n";
for(i = R; i < v.size(); i++)
st.insert({v[i].se, v[i].fi});
if(m == 1)
cout<<st.size()<<"\n";
for(i = 0; i < B; i++){
y = m;
while((y--) && st.size() && st.begin()->fi < Y[i])
st.erase(st.begin());
}
if(st.size())
l = m + 1;
else
r = m;
}
return l;
}
/*
int main(){
TL;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
cout<<putaway(2 , 1 , 3 , {2 , 5} , {2} , {3 , 5 , 2} , {1 , 3 , 2})<<"\n";
}*/
// Author : حسن