Submission #386270

#TimeUsernameProblemLanguageResultExecution timeMemory
386270jjang36524Robots (IOI13_robots)C++14
0 / 100
6 ms5356 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[100100]; 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=lower_bound(X,X+A,W[i])-X; int y=lower_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; 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; } } int c=0; for(i=0;i<B;i++) { int j; for(j=0;j<Sl[i].size();j++) { if(!us[Sl[i][j]]) { c++; } } c=max(0,c-m); } if(c) 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:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |             for(j=0;j<Wl[i].size();j++)
      |                     ~^~~~~~~~~~~~~
robots.cpp:55:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             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...