Submission #109553

#TimeUsernameProblemLanguageResultExecution timeMemory
109553Nodir_BobievRobots (IOI13_robots)C++14
100 / 100
1907 ms24548 KiB
# include "robots.h" # include <iostream> # include <algorithm> # include <queue> using namespace std; int putaway( int A, int B, int T, int X[], int Y[], int W[], int S[] ) { pair < int, int > ws[T]; for ( int i = 0; i < T; i ++ ) ws[i] = { W[i], S[i] }; sort( X, X + A ); sort( Y, Y + B ); reverse( Y, Y + B ); sort( ws, ws + T ); int l = -1, r = T + 1, ans = -1; while( r - l > 1 ){ int m = ( l + r ) >> 1, j = 0; priority_queue < int > pq; for ( int i = 0; i < A; i ++ ){ while( j < T && ws[j].first < X[i] ) pq.push( ws[ j++ ].second ); int k = m; while( k > 0 && !pq.empty() ){ pq.pop(); k --; } } while( j < T ) pq.push( ws[ j++ ].second ); for ( int i = 0; i < B; i ++ ){ int t = false, k = m; while( k > 0 && !pq.empty() ){ if( pq.top() >= Y[i] ){ t = true; break; } pq.pop(); k--; } if( t || pq.empty() ) break; } if( pq.empty() ){ r = m; ans = m; } else{ l = m; } } return ans; } /* int main() { int A, B, T; int X[100] = {}, Y[100] = {}; int W[100] = {}, S[100] = {}; cin >> A >> B >> T; for ( int i = 0; i < A; i ++ ) cin >> X[i]; for ( int i = 0; i < B; i ++ ) cin >> Y[i]; for ( int i = 0; i < T; i ++ ) cin >> W[i] >> S[i]; cout << putaway( A, B, T, X, Y, W, S ); return 0; } /**/

Compilation message (stderr)

robots.cpp:95:1: warning: "/*" within comment [-Wcomment]
 /**/
#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...