제출 #109445

#제출 시각아이디문제언어결과실행 시간메모리
109445Nodir_Bobiev로봇 (IOI13_robots)C++14
0 / 100
3 ms512 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 = 0, r = T, 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 );
				j ++;
			}
			int k = 0;
			while( k < m && !pq.empty() ){
				pq.pop();
				k++;
			}
		}
	
		for (j; j < T; j ++ )
			pq.push( ws[j].second );
		
		for ( int i = 0; i <= B; i ++ ){
			bool t = false; int k = 0;
			while( k < m && !pq.empty() ){
				k++;
				if( pq.top() > Y[i] ){
					t = true;
					break;
				}
				pq.pop();
			}
			if( t )
				break;
		}
		
		if( pq.empty() ){
			r = m ;
			ans = m;
		}
		else{
			l = m;
		}
	}
	return ans; 
}
/*
int main()
{
	int A, B, T;
	int X[100] = {};
	int 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;
}
*/

컴파일 시 표준 에러 (stderr) 메시지

robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:39:9: warning: statement has no effect [-Wunused-value]
   for (j; j < T; 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...