# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
931283 | AlphaMale06 | Robots (IOI13_robots) | C++17 | 1345 ms | 26384 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"
#define F first
#define S second
#define pb push_back
using namespace std;
int putaway(int n, int m, int S, int a[], int b[], int w[], int s[]) {
pair<int, int> p[S];
for(int i=0; i< S; i++)p[i]={w[i], s[i]};
sort(p, p+S);
sort(a, a+n);
sort(b, b+m);
for(int i=0; i< n; i++)a[i]--;
for(int i=0; i< m; i++)b[i]--;
int ans=1e9;
int l=0, r = S;
while(l<=r){
int s=l+r>>1;
priority_queue<int> st;
int pt=0;
for(int i=0; i< n; i++){
while(pt<S && p[pt].F<=a[i]){
st.push(p[pt].S);
pt++;
}
int to = min(s, (int)st.size());
for(int j=0; j<to; j++){
st.pop();
}
}
while(pt<S){
st.push(p[pt].S);
pt++;
}
vector<int> v;
while(st.size()){
v.pb(st.top());
st.pop();
}
reverse(v.begin(), v.end());
for(int i = m-1; i>=0; i--){
for(int j=0; j<s; j++){
if(v.size()){
if(v.back()<=b[i]){
v.pop_back();
}
else break;
}
else break;
}
}
if(v.size()){
l=s+1;
}
else{
r=s-1;
ans=s;
}
}
if(ans==1e9)return -1;
return ans;
}
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... |