# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1036354 | MSK17 | Robots (IOI13_robots) | C++17 | 3088 ms | 42420 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 "robots.h"
#include <bits/stdc++.h>
int putaway(int a, int b, int t, int X[], int Y[], int w[], int s[]) {
std::vector<std::pair<int,int>> toys(t);
std::vector<int> x(a), y(b);
for(int i{}; i < a; ++i)
x[i]=X[i];
for(int i{}; i < b; ++i)
y[i]=Y[i];
std::sort(x.begin(), x.end());
std::sort(y.begin(), y.end());
for(int i{}; i < t; ++i){
toys[i].first=w[i];
toys[i].second=s[i];
}
std::sort(toys.begin(), toys.end());
for(int i{}; i < t; ++i){
if((a==0||toys[i].first>=x[a-1])&&(b==0||toys[i].second>=y[b-1]))
return -1;
}
int l=0, r=t;
while(r-l>1){
int m=(l+r)/2;
int cur=0;
std::multiset<int> st;
for(int i{}; i < a; ++i){
while(cur<toys.size()&&toys[cur].first<x[i]){
st.insert(toys[cur].second);
++cur;
}
for(int j{}; j < m; ++j){
if(st.size()>0){
int max=*(st.rbegin());
st.erase(st.find(max));
}
else break;
}
}
while(cur<toys.size()){
st.insert(toys[cur].second);
++cur;
}
for(int i{}; i < b; ++i){
for(int j{}; j < m; ++j){
if(st.size()==0)
break;
int min=*(st.begin());
if(min<y[i])
st.erase(st.find(min));
else break;
}
}
if(st.size()==0)
r=m;
else
l=m;
}
return r;
}
Compilation message (stderr)
# | 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... |