Submission #291327

#TimeUsernameProblemLanguageResultExecution timeMemory
291327BadrangiikhRobots (IOI13_robots)C++14
14 / 100
1947 ms22372 KiB
#include "robots.h" #include<bits/stdc++.h> using namespace std; int n , m , k , l , r , mid , x , y , z , ans , cnt , s1 , s2 , s3 , s4 ; int *weak ; int *smol ; pair < int , int > toy [ 1000005 ] ; int *w ; int *s ; priority_queue < int > pq , pp ; vector < int > vc , vv ; bool check ( int s1 ) { pq = pp ; int s2 = 0 ; for ( int i = 0 ; i < m ; i ++ ) { while ( s2 < n && toy [ s2 ] . first < weak [ i ] ) { pq . push ( s [ toy [ s2 ] . second ] ) ; s2 ++ ; } s3 = s1 ; while ( s3 -- && pq . size ( ) > 0 ) pq . pop ( ) ; } for ( ; s2 < n ; s2 ++ ) { pq . push ( s [ toy [ s2 ] . second ] ) ; } vc = vv ; while ( pq . size ( ) > 0 ) { vc . push_back ( pq . top ( ) ) ; pq . pop ( ) ; } reverse ( vc . begin ( ) , vc . end ( ) ) ; s2 = 0 ; s3 = s1 ; for ( int i = 0 ; i < vc . size ( ) ; i ++ ){ while ( s2 < k && ( !s3 || vc [ i ] >= smol [ s2 ] ) ){ s2 ++ ; s3 = s1 ; } if ( s2 == k ) return 0 ; s3 -- ; } return 1 ; } int putaway ( int A, int B, int T, int X[], int Y[], int W[], int S[] ) { m = A ; k = B ; n = T ; weak = X ; sort ( weak , weak + m ) ; smol = Y ; sort ( smol , smol + k ) ; w = W ; s = S ; for ( int i = 0 ; i < n ; i ++ ) { if ( w [ i ] > weak [ m - 1 ] && s [ i ] > smol [ k - 1 ] ) { return -1 ; } toy [ i ] . first = w [ i ] ; toy [ i ] . second = i ; } sort ( toy , toy + n ) ; l = 1 ; r = n ; while ( l < r ) { mid = ( l + r ) / 2 ; if ( check ( mid ) == 1 ) r = mid ; else l = mid + 1 ; } return l ; }

Compilation message (stderr)

robots.cpp: In function 'bool check(int)':
robots.cpp:36:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for ( int i = 0 ; i < vc . size ( ) ; i ++ ){
      |                       ~~^~~~~~~~~~~~~~~
#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...