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>
using namespace std;
typedef long long ll;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
vector<int> a(X, X+A), b(Y, Y+B);
vector<pair<int, int>> t(T);
for(int i = 0; i <T; i ++) { t[i] = {W[i], S[i]};}
sort(a.begin(), a.end());
sort(b.begin(), b.end());
sort(t.begin(), t.end());
int l = 1;
int r = T+1;
while(l <r)
{
int mid = (l + r)/2;
//cout << l << " " << r << " " << '\n';
priority_queue<int> taken;
int toyid = 0;
for(int aid = 0; aid <A; aid ++)
{
while(t[toyid].first < a[aid] && toyid < T)
{
taken.push(t[toyid].second);
toyid ++;
}
for(int i = 0; i < mid && !taken.empty(); i ++)
{
taken.pop();
}
}
for(; toyid < T; toyid ++)
{
taken.push(t[toyid].second);
}
for(int i = B-1; i >=0 &&!taken.empty(); i --)
{
for(int j = mid-1; j >= 0 && !taken.empty(); j --)
{
if(taken.top() >= b[i])
{
break;
}
else {taken.pop();}
}
}
if(taken.empty())
{
r = mid;
}
else { l = mid + 1;}
}
if(l == T+1)
{
return -1;
}
else
{
return l;
}
}
# | 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... |