제출 #706820

#제출 시각아이디문제언어결과실행 시간메모리
706820Doncho_Bonboncho로봇 (IOI13_robots)C++14
0 / 100
3059 ms8584 KiB
#include "robots.h" #include <bits/stdc++.h> const int MAX_N = 1e6 + 42; std::pair<int, int> toys[MAX_N]; int small[MAX_N]; int weak[MAX_N]; int a, b, t; bool f( int x ){ std::priority_queue<int> q; int ind = -1; for( int i=0 ; i<a ; i++ ){ while( toys[ind+1].first < weak[i] ){ q.push(toys[ind+1].second); ind++; } int num = x; while( !q.empty() and num ){ num--; q.pop(); } } while( ind+1 < t ){ q.push( toys[ind+1].second ); ind++; } for( int i = b-1 ; i>=0 ; i-- ){ if( q.empty() ) return true; int num = x; while( !q.empty() and num ){ if( q.top() >= small[i] ) return false; q.pop(); num--; } } return q.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A; b = B; t = T; for( int i=0 ; i<a; i++ ) weak[i] = X[i]; for( int i=0 ; i<b; i++ ) small[i] = Y[i]; for( int i=0 ; i<t ; i++ ) toys[i] = {W[i], S[i]}; std::sort( weak, weak + a ); std::sort( small, small + b ); std::sort( toys, toys + t ); int l = 0, r = t; while( l != r-1 ){ int m = ( l + r ) << 1; if( f( m ) ) l = m; else r = m; } if( !f(r) ) return -1; return r; }
#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...