이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <utility>
#include <iostream>
#include <tuple>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;
#include "robots.h"
bool sbs(tuple<int,int,int> a,tuple<int,int,int> b){
int q,w,e,r,t,y;
tie(q,w,e) = a;
tie(r,t,y) = b;
if(w == t){
if(q == r){
return e < y;
}
return q < r;
}
return w < t;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
vector<pair<int,int>> ok;
for (int i = 0; i < T; ++i){
ok.push_back({S[i],W[i]});
}
sort(X,X+A);
reverse(X,X+A);
sort(Y,Y+B);
reverse(Y,Y+B);
vector<tuple<int,int,int>> vss;
for (int i = 0; i < T; ++i){
vss.push_back({W[i],S[i],i});
}
sort(vss.begin(), vss.end(),sbs);
int l = (T+A+B-1)/(A+B),r = T,ans = -1;
while(l <= r){
int mid = (l+r)/2;
bool good = true;
multiset<int> ava;
vector<int> v;
vector<int> ad;
// (S W) (Y X)
priority_queue<pair<int,int>> q;
for (int i = 0; i < min(T,A*mid); ++i){
ava.insert(X[i/mid]);
}
for (int i = 0; i < min(T,B*mid); ++i){
ad.push_back(Y[i/mid]);
}
for (int i = 0; i < T; ++i){
q.push(ok[i]);
}
vector<int> rest;
while(size(q)){
auto fr = q.top();q.pop();
auto fl = ava.upper_bound(fr.second);
if(fl == ava.end()){
rest.push_back(fr.first);
}else{
ava.erase(fl);
}
}
sort(rest.begin(), rest.end());
reverse(rest.begin(), rest.end());
for(int i = 0; i < size(rest);i++){
if(ad[i] <= rest[i]){
good = false;
break;
}
}
if(good){
ans = mid;
r = mid-1;
}else{
l = mid+1;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:70:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 0; i < size(rest);i++){
~~^~~~~~~~~~~~
# | 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... |