이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"robots.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n, a, b;
vector<pair<int, int> >v;
vector<int>vv[50005];
bool ok(int x){
int sisa=0;
vector<int>isi;
priority_queue<int>pq;
for(int i=0; i<vv[0].size(); i++)
isi.push_back(vv[0][i]);
for(int i=1; i<=a; i++){
int siz=vv[i].size();
for(int j=0; j<siz; j++)
pq.push(vv[i][j]);
if(sisa>=siz-x) sisa+=x-siz;
else{
for(int j=1; j<=siz-x-sisa; j++){
if(pq.empty()) return false;
isi.push_back(pq.top()); pq.pop();
}
sisa=0;
}
}
sort(isi.begin(), isi.end());
for(int i=0; i<isi.size(); i++){
int tmp=i/x+1;
if(tmp>b || tmp>isi[i]) return false;
}
return true;
}
int32_t putaway(int32_t _a, int32_t _b, int32_t _t, int32_t x[], int32_t y[], int32_t w[], int32_t s[]){
n=_t;
a=_a; b=_b;
sort(x, x+a); sort(y, y+b);
v.resize(n);
for(int i=0; i<n; i++)
v[i]=make_pair(w[i], s[i]);
for(int i=0; i<n; i++){
int l=0, r=a-1, md, wt, sz;
while(l<=r){
md=(l+r)/2;
if(v[i].first<x[md]){
wt=a-md;
r=md-1;
}else l=md+1;
}
l=0, r=b-1;
while(l<=r){
md=(l+r)/2;
if(v[i].second<y[md]){
sz=b-md;
r=md-1;
}else l=md+1;
}
vv[wt].push_back(sz);
}
int ans=-1;
int l=1, r=n, md;
while(l<=r){
md=(l+r)/2;
if(ok(md)){
ans=md; r=md-1;
}else l=md+1;
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool ok(long long int)':
robots.cpp:12:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<vv[0].size(); i++)
~^~~~~~~~~~~~~
robots.cpp:28:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<isi.size(); 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... |