제출 #31944

#제출 시각아이디문제언어결과실행 시간메모리
31944szawinis로봇 (IOI13_robots)C++14
100 / 100
2866 ms18692 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int MAX = (1e6)+1; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector<pair<int,int> > toys; for(int i = 0; i < T; i++) toys.emplace_back(W[i], S[i]); sort(toys.begin(), toys.end()); sort(X, X+A); sort(Y, Y+B); auto check = [&] (int lim) { priority_queue<pair<int,int> > pq; bitset<MAX> mark; int j = 0; for(int i = 0; i < A; i++) { while(j < toys.size() && toys[j].first < X[i]) { pq.emplace(toys[j].second, j); ++j; } for(int k = 0; k < lim && !pq.empty(); k++) { mark[pq.top().second] = 1; pq.pop(); } } while(j < toys.size()) pq.emplace(toys[j].second, j), ++j; for(int i = B-1; i >= 0; i--) { for(int k = 0; k < lim && !pq.empty() && pq.top().first < Y[i]; k++) { mark[pq.top().second] = 1; pq.pop(); } } return mark.count() == T; }; int l = 1, r = T; while(l < r) { int mid = l+r >> 1; if(check(mid)) r = mid; else l = mid+1; } if(!check(l)) return -1; else return l; }

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

robots.cpp: In lambda function:
robots.cpp:17:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    while(j < toys.size() && toys[j].first < X[i]) {
            ^
robots.cpp:26:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(j < toys.size()) pq.emplace(toys[j].second, j), ++j;
           ^
robots.cpp:33:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   return mark.count() == T;
                       ^
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:37:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l+r >> 1;
              ^
#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...