Submission #29835

#TimeUsernameProblemLanguageResultExecution timeMemory
29835osmanorhanRobots (IOI13_robots)C++14
100 / 100
2186 ms15108 KiB
#include "robots.h" #include <bits/stdc++.h> #define all( x ) x.begin(), x.end() #define fi first #define se second #define pb push_back using namespace std; typedef pair<int,int> ii; vector<ii> v; vector<int> w, s; bool f( int n ) { priority_queue<int> q; int j = 0; for(int i=0;i<w.size();i++) { while( j < v.size() && v[j].fi < w[i] ) q.push( v[j].se ), j++; int tr = n; while( tr-- > 0 && !q.empty() ) q.pop(); } while( j < v.size() ) q.push( v[j].se ), j++; if( q.empty() ) return 1; for(int i=s.size()-1;i>=0;i--) { if( q.top() >= s[i] ) return 0; int tr = n; while( tr-- > 0 && !q.empty() ) q.pop(); if( q.empty() ) return 1; } return 0; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { for(int i=0;i<T;i++) v.pb( ii( W[i], S[i] ) ); sort( all( v ) ); sort( X, X+A ); sort( Y, Y+B ); for(int i=0;i<A;i++) w.pb( X[i] ); for(int i=0;i<B;i++) s.pb( Y[i] ); int t = 0; for(int k=19;k>=0;k--) if( !f( t+(1<<k) ) ) t += 1<<k; t++; if( !f( t ) ) return -1; return t; }

Compilation message (stderr)

robots.cpp: In function 'bool f(int)':
robots.cpp:18:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++) {
                  ^
robots.cpp:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while( j < v.size() && v[j].fi < w[i] ) q.push( v[j].se ), j++;
                  ^
robots.cpp:23:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while( j < v.size() ) q.push( v[j].se ), 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...