제출 #210141

#제출 시각아이디문제언어결과실행 시간메모리
210141mohamedsobhi777로봇 (IOI13_robots)C++14
100 / 100
1761 ms46996 KiB
#include "robots.h" #include <bits/stdc++.h> const int N = 1e6 + 6 ; using namespace std ; int AA , BB , TT ; vector<int> XX , YY , WW , SS ; vector<int> appear[N] ; bool check(int x){ priority_queue<int> q ; for(int i = 0 ; i < AA ; i++){ for(int j = 0 ; j < appear[i].size() ; j++){ q.push(appear[i][j]) ; } int sz = min((int)q.size() , x) ; for(int j = 0 ; j < sz ; j++){ q.pop() ; } } for(int i = 0 ; i < appear[AA].size() ; i++){ q.push(appear[AA][i]) ; } for(int i = 0 ; i < BB ; i++){ int sz = min((int)q.size() , x ) ; for(int j = 0 ; j < sz ; j++){ if(q.top() < YY[i]) { q.pop() ; } else break; } } return !q.size(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { AA = A ; BB = B ; TT = T ; for(int i = 0 ; i < A ; i++){ XX.push_back(X[i]) ; } for(int i = 0 ; i < B ; i++){ YY.push_back(Y[i]) ; } sort(XX.begin() , XX.end()) ; sort(YY.begin() , YY.end()) ; for(int i = 0 ; i < T ; i++){ int i1 = upper_bound(XX.begin() , XX.end() , W[i] ) - XX.begin() ; int i2 = upper_bound(YY.begin() , YY.end(), S[i]) - YY.begin() ; if(i1==A && i2==B) return -1 ; appear[i1].push_back(S[i]) ; } for(int i = 0 ; i < A ; i++){ sort(appear[i].begin() , appear[i].end() , greater<int>()) ; } sort(YY.begin() , YY.end(), greater<int>()) ; int l = 1 , r = T ; int ans = -1; while(l<=r){ int mid = (l+r) /2; if(check(mid)){ ans = mid ; r = mid - 1 ; } else{ l = mid + 1 ; } } return ans ; }

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

robots.cpp: In function 'bool check(int)':
robots.cpp:16:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(int j = 0 ; j < appear[i].size() ; j++){
                             ~~^~~~~~~~~~~~~~~~~~
robots.cpp:24:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i = 0 ; i < appear[AA].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...