Submission #30049

#TimeUsernameProblemLanguageResultExecution timeMemory
30049inqrRobots (IOI13_robots)C++14
0 / 100
23 ms6324 KiB
#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=1e7; 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,tswind=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; } for(int j=0;j<m && pq.size();j++){ printf(" %d pop\n",pq.top()); pq.pop();// m kadarlari pq dan attik } } for(int i=0;i<src;i++){ for(int j=0;j<m;j++){ if(pq.size()){ if(pq.top()<=sr[i]){ pq.pop(); } } } } if(pq.size()){ l=m+1; } else{ r=m; ans=min(ans,m); } } return ans; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:33:16: warning: unused variable 'tswind' [-Wunused-variable]
   int twsind=0,tswind=0;
                ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...