# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164387 | nafis_shifat | Robots (IOI13_robots) | C++14 | 2505 ms | 28764 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>
#define pii pair<int,int>
#define f first
#define s second
#define ll long long
using namespace std;
vector<pii> toy;
vector<int> wt;
vector<int> st;
bool can(int s)
{
priority_queue<pii> pq;
int pnt=0;
for(int i=0;i<st.size();i++)
{
while(pnt<toy.size()&&toy[pnt].f<st[i])
{
pq.push({toy[pnt].s,toy[pnt++].f});
}
for(int j=0;j<s && !pq.empty();j++)
{
pq.pop();
}
}
for(;pnt<toy.size();pnt++)pq.push({toy[pnt].s,toy[pnt].f});
for(int i=wt.size()-1;i>=0;i--)
{
for(int j=0;j<s && !pq.empty() && pq.top().f<wt[i];j++)
{
pq.pop();
}
}
return pq.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
for(int i=0;i<T;i++)toy.emplace_back(S[i],W[i]);
for(int i=0;i<A;i++)wt.push_back(X[i]);
for(int i=0;i<B;i++)st.push_back(Y[i]);
sort(toy.begin(), toy.end());
sort(st.begin(),st.end());
sort(wt.begin(),wt.end());
int lo=1;
int hi= T;
int r=-1;
while(lo<=hi)
{
int mid=lo+hi>>1;
bool f=can(mid);
if(f)
{
hi=mid-1;
r=mid;
}
else
{
lo=mid+1;
}
}
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... |