이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int n,a,b,x[50005],y[50005];
pii data[1000005];
bool check(int c)
{
ll sz=0;
vector<int> v;
priority_queue<int,vector<int>,greater<int>> pq;
for(int i=0,nw=a-1;i<n;++i)
{
while(nw>=0&&x[nw]>data[i].F)
--nw,sz+=c;
pq.push(data[i].S);
while(pq.size()>sz) v.pb(pq.top()),pq.pop();
}
sort(ALL(v),greater<int>()),sz=0;
for(int i=0,nw=b-1;i<v.size();++i)
{
while(nw>=0&&y[nw]>v[i])
--nw,sz+=c;
if(i>=sz) return 0;
}
return 1;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
n=T,a=A,b=B;
int l=1,r=T+1;
for(int i=0;i<T;++i)
data[i]=MP(W[i],S[i]);
for(int i=0;i<A;++i)
x[i]=X[i];
for(int i=0;i<B;++i)
y[i]=Y[i];
sort(data,data+T,greater<pii>()),sort(x,x+a),sort(y,y+b);
while(l<r)
{
int m=l+r>>1;
if(check(m)) r=m;
else l=m+1;
}
if(l==T+1) return -1;
return l;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool check(int)':
robots.cpp:31:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(pq.size()>sz) v.pb(pq.top()),pq.pop();
~~~~~~~~~^~~
robots.cpp:34:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0,nw=b-1;i<v.size();++i)
~^~~~~~~~~
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:56:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
int m=l+r>>1;
~^~
# | 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... |