이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "robots.h"
using namespace std;
const int nmax=1e6+42;
vector< pair<int/*weight*/,int/*size*/> > robots;
vector<int> SIZES;
priority_queue<int> q,emp;
bool can(int t)
{
q=emp;
for(auto k:robots)
if(k.second!=-1)q.push(k.second);
else
{
int rem=q.size();
if(rem>t)rem=t;
for(int j=1;j<=rem;j++)
q.pop();
}
if(q.size()==0)return 1;
for(auto k:SIZES)
{
if(q.top()>k)return 0;
if(q.size()<=t)return 1;
for(int j=1;j<=t;j++)
q.pop();
}
return 0;
}
bool cmp(pair<int/*weight*/,int/*size*/> a,pair<int/*weight*/,int/*size*/> b)
{
if(a.first!=b.first)return a.first<b.first;
return a.second>b.second;
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
for(int i=0;i<A;i++)X[i]--;
for(int i=0;i<B;i++)Y[i]--;
for(int i=0;i<T;i++)robots.push_back({W[i],S[i]});
for(int i=0;i<A;i++)robots.push_back({X[i],-1});
sort(robots.begin(),robots.end(),cmp);
sort(Y,Y+B);
reverse(Y,Y+B);
for(int j=0;j<B;j++)SIZES.push_back(Y[j]);
int ok=T+1,not_ok=-1;
while(ok-not_ok>1)
{
int av=(ok+not_ok)/2;
if(can(av))ok=av;
else not_ok=av;
}
if(not_ok==T)return -1;
return ok;
}
/*
const int A=3,B=2,T=10;
int X[A]={6,2,9};
int Y[B]={4,7};
int W[T]={4,8,2,7,1,5,3,8,7,10};
int S[T]={6,5,3,9,8,1,3,7,6,5};
int main()
{
cout<<putaway(A,B,T,X,Y,W,S)<<endl;
}
*/
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool can(int)':
robots.cpp:24:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(q.size()<=t)return 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... |