Submission #419686

#TimeUsernameProblemLanguageResultExecution timeMemory
419686pliamRobots (IOI13_robots)C++14
53 / 100
802 ms38992 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; #define INF (int)1000000005 struct robot{ vector<int> lim;//limits of size/weight multiset<int> rem;//remaining toys(their size/weight) robot(vector<int> input){//input the limits for robots lim=input; rem.clear(); sort(lim.begin(),lim.end()); } int work(int size){ if(lim.size()==0) return 0; auto it=upper_bound(lim.begin(),lim.end(),size);//first robot capable (limit > size) return lim.end()-it; } void insert(int size){ rem.insert(size); } int time(){ if(lim.size()==0){ if(rem.size()==0) return 0; else return INF; } int t=0; int pos=0;//lowest id of working robot while(rem.size()>0){ for(int i=lim.size()-1;i>=pos;i--){ auto it=rem.lower_bound(lim[i]); if(it==rem.begin()){ pos=i+1; break; }else{ it--; rem.erase(it); } } if(pos==lim.size()) return INF; t++; } return t; } }; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { robot robotA=robot(vector<int>(X,X+A)); robot robotB=robot(vector<int>(Y,Y+B)); for(int i=0;i<T;i++){ if(robotA.work(W[i])>robotB.work(S[i])){ robotA.insert(W[i]); }else{ robotB.insert(S[i]); } } int ans=max(robotA.time(),robotB.time()); return ans==INF?-1:ans; }

Compilation message (stderr)

robots.cpp: In member function 'int robot::time()':
robots.cpp:44:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |             if(pos==lim.size()) return INF;
      |                ~~~^~~~~~~~~~~~
#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...