Submission #386274

#TimeUsernameProblemLanguageResultExecution timeMemory
386274jjang36524Robots (IOI13_robots)C++14
100 / 100
2300 ms38124 KiB
#include "robots.h" #include <algorithm> #include <queue> #include <vector> #include <string.h> using namespace std; vector<int>Wl[100000]; vector<int>Sl[100000]; int us[1000100]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X,X+A); sort(Y,Y+B); int i; for(i=0;i<T;i++) { int x=upper_bound(X,X+A,W[i])-X; int y=upper_bound(Y,Y+B,S[i])-Y; if(x==A&&y==B) { return -1; } Wl[x].push_back(i); Sl[y].push_back(i); } int s=1; int e=T; while(s!=e) { int m=(s+e)/2; priority_queue<pair<int,int>>tc; memset(us,0,sizeof(us)); int i; int c=0; for(i=0;i<A;i++) { int j; for(j=0;j<Wl[i].size();j++) { tc.push({S[Wl[i][j]],Wl[i][j]}); } for(j=0;j<m;j++) { if(tc.empty()) break; auto a=tc.top(); tc.pop(); us[a.second]=1; c++; } } int cc=0; for(i=0;i<B;i++) { int j; for(j=0;j<Sl[i].size();j++) { if(!us[Sl[i][j]]) { cc++; } } if(cc>=m) c+=m; else c+=cc; cc=max(0,cc-m); } if(c!=T) s=m+1; else e=m; } return s; }

Compilation message (stderr)

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for(j=0;j<Wl[i].size();j++)
      |                     ~^~~~~~~~~~~~~
robots.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             for(j=0;j<Sl[i].size();j++)
      |                     ~^~~~~~~~~~~~~
#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...