이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define rt insert
#define st first
#define nd second
#define ll long long
#define pii pair < int , int >
#define DB printf("debug\n");
using namespace std;
int wrc,src,tn;
vector < int > wr;
vector < int > sr;
vector < pii > tws;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
wrc=A;src=B;tn=T;
for(int i=0;i<tn;i++){
tws.pb(mp(W[i],S[i]));
}
sort(tws.begin(),tws.end());
for(int i=0;i<wrc;i++)wr.pb(X[i]);
for(int i=0;i<src;i++)sr.pb(Y[i]);
sort(wr.begin(),wr.end());
sort(sr.begin(),sr.end());reverse(sr.begin(),sr.end());
int l=0,r=1e7,m,ans=1e9;
priority_queue < int > pq;
while(l<r){
m=(l+r)/2;
pq = priority_queue < int > ();
//printf("l=%d r=%d m=%d\n",l,r,m);
int twsind=0;
for(int i=0;i<wrc;i++){// eklicegimiz robotu aldik
//printf(" i=%d wrc=%d\n",i,wr[i]);
for(int j=twsind;tws[j].st<wr[i] && j<tn;j++){//eklicemiz robota kalan olan toylari ekledik
//printf(" j=%d tws= %d %d\n",j,tws[j].st,tws[j].nd);
pq.push(tws[j].nd);
twsind=j+1;
}
for(int j=0;j<m && pq.size();j++){
//printf(" %d pop\n",pq.top());
pq.pop();// m kadarlari pq dan attik
}
}
for(int j=twsind;j<tn;j++){//eklicemiz robota kalan olan toylari ekledik
//printf("j=%d tws= %d %d\n",j,tws[j].st,tws[j].nd);
pq.push(tws[j].nd);
}
for(int i=0;i<src;i++){
for(int j=0;j<m;j++){
if(pq.size()){
if(pq.top()<sr[i]){
pq.pop();
}
else if(r==1e7) return -1;
}
}
}
if(pq.size()){
l=m+1;
}
else{
r=m;
ans=min(ans,m);
}
}
return ans;
}
# | 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... |