Submission #83909

#TimeUsernameProblemLanguageResultExecution timeMemory
83909nikolapesic2802Robots (IOI13_robots)C++14
100 / 100
2468 ms17212 KiB
#include <bits/stdc++.h> #include "robots.h" #define pb push_back using namespace std; pair<int,int> maxx=make_pair(INT_MAX,INT_MAX); int putaway(int a, int b, int t, int x[], int y[], int W[], int S[]) { sort(x,x+a); sort(y,y+b); reverse(y,y+b); vector<pair<int,int> > items(t); for(int i=0;i<t;i++) { items[i].first=W[i]; items[i].second=S[i]; } items.pb(maxx); sort(items.begin(),items.end()); int l=1,r=t+5; while(l<r) { int mid=(l+r)/2; //printf("%i\n",mid); int j=0; int test=true; int cnt=0; priority_queue<pair<int,int> > s; for(int i=0;i<a;i++) { //printf("Usao za %i\n",x[i]); while(items[j].first<x[i]) { //printf("Dodajem %i %i\n",items[j].first,items[j].second); s.push({items[j].second,cnt++}); j++; } for(int k=0;k<mid;k++) { if(s.empty()) break; s.pop(); //printf("brisem!\n"); } } for(;j<t;j++) s.push({items[j].second,cnt++}); for(int i=0;i<b;i++) { //printf("usao! %i\n",y[i]); for(int k=0;k<mid;k++) { if(s.size()==0) { break; break; } if((s.top().first)<y[i]) s.pop(); else { break; break; } } } if(s.size()!=0) test=false; if(test) { r=mid; } else { l=mid+1; } while(!s.empty()) s.pop(); } if(l==t+5) return -1; return l; }
#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...