Submission #392218

#TimeUsernameProblemLanguageResultExecution timeMemory
392218cpp219Robots (IOI13_robots)C++14
100 / 100
2137 ms37980 KiB
#include<bits/stdc++.h> #define ll int #define ld long double #define fs first #define sc second using namespace std; typedef pair<ll,ll> LL; const ll N = 300 + 9; const ll mod = 1e9 + 7; #include "robots.h" 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:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             for(j=0;j<Wl[i].size();j++)
      |                     ~^~~~~~~~~~~~~
robots.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |             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...