이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
#define all(v) v.begin(), v.end()
const int NMAX = 1e6 + 5;
int A, B, T, X[NMAX], Y[NMAX], W[NMAX], S[NMAX];
int go(int A, int B, int T, int X[], int Y[], int W[], int S[], int m){
vector<pair<int, int>> v;
priority_queue<int> pq;
for(int i = 0; i < T; i++) v.emplace_back(W[i], S[i]);
sort(all(v));
int ix = 0;
for(int i = 0; i < A; i++){
while(ix < v.size() && v[ix].first < X[i]) pq.emplace(v[ix++].second);
for(int j = 0; j < m; j++){
if(pq.size()) pq.pop();
else break;
}
}
while(ix < v.size()) pq.emplace(v[ix++].second);
for(int i = B - 1; i >= 0; i--){
for(int j = 0; j < m; j++){
if(pq.size() && Y[i] > pq.top()) pq.pop();
else break;
}
}
return pq.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){
int l = 1, r = T + 1, m;
sort(X, X + A);
sort(Y, Y + B);
while(l < r){
m = (l + r) / 2;
cout << l << ' ' << r << '\n';
if(go(A, B, T, X, Y, W, S, m)) r = m;
else l = m + 1;
}
return l == T + 1 ? -1 : l;
}
/*
int main(void){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
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 go(int, int, int, int*, int*, int*, int*, int)':
robots.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
17 | while(ix < v.size() && v[ix].first < X[i]) pq.emplace(v[ix++].second);
| ~~~^~~~~~~~~~
robots.cpp:23:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | while(ix < v.size()) pq.emplace(v[ix++].second);
| ~~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |