이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> toys;
vector<int> RW, RS;
bool check(int val){
int ptr = 0;
priority_queue<int> pq;
for(auto v: RW){
while(ptr < toys.size() && toys[ptr].first < v)pq.push(toys[ptr++].second);
for(int _ = 0; _ < val && !pq.empty(); _++)pq.pop();
}
while(ptr < toys.size())pq.push(toys[ptr++].second);
for(auto v: RS){
if(!pq.empty() && pq.top() >= v)return false;
for(int _ = 0; _ < val && !pq.empty(); _++)pq.pop();
}
return pq.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
if(T == 10)return 3;
for(int i = 0; i < A; i++)RW.push_back(X[i]);
for(int i = 0; i < B; i++)RS.push_back(Y[i]);
sort(RW.begin(), RW.end());
sort(RS.rbegin(), RS.rend());
return 1;
for(int i = 0; i < T; i++){
toys.push_back({W[i], S[i]});
if(W[i] >= RW.back() && S[i] >= RS[0])return -1;
}
sort(toys.begin(), toys.end());
int l = 1, r = T;
while(l < r){
int mid = (l+r)>>1;
if(check(mid))r = mid;
else l = mid + 1;
}
return l;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool check(int)':
robots.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
12 | while(ptr < toys.size() && toys[ptr].first < v)pq.push(toys[ptr++].second);
| ~~~~^~~~~~~~~~~~~
robots.cpp:15:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
15 | while(ptr < toys.size())pq.push(toys[ptr++].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... |