이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define INF 1e18
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define OK cout<<"Ok"<<endl;
#define MOD (ll)(1e9+7)
#define endl "\n"
const int mxn=1e6+5;
int n,a,b;
vector<int>l,r;
vector<pii>arr;
bool check(int k){
priority_queue<int>q;
int idx=0;
for(int i=0;i<a;i++){
while(idx<n&&arr[idx].F<l[i]){
q.push(arr[idx].S);
idx++;
}
int say=min(k,(int)q.size());
while(say--){
q.pop();
}
}
while(idx<n){
q.push(arr[idx].S);
idx++;
}
for(int i=0;i<b;i++){
int say=min((int)q.size(),k);
while(say--){
if(q.top()<r[i]){
q.pop();
}
else{
return false;
}
}
}
if(q.size()) return false;
return true;
}
int putaway(int A, int B, int N, int X[], int Y[], int W[], int S[]) {
n=N;
a=A;
b=B;
for(int i=0;i<a;i++){
l.pb(X[i]);
}
for(int i=0;i<b;i++){
r.pb(Y[i]);
}
for(int i=0;i<n;i++){
arr.pb({W[i],S[i]});
}
sort(all(l));
sort(rall(r));
sort(all(arr));
int l=1,rr=n+1;
while(l<=rr){
int m=(l+rr)/2;
if(check(m)){
rr=m-1;
}
else{
l=m+1;
}
}
rr++;
if(rr>n){
return -1;
}
else{
return rr;
}
}
# | 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... |