# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
68300 | MKopchev | Robots (IOI13_robots) | C++14 | 0 ms | 0 KiB |
이 제출은 이전 버전의 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,vector<int> X/*w,a*/,vector<int> Y/*s,b*/,vector<int> W/*t*/,vector<int> S/*t*/)
{
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.begin(),Y.end());
reverse(Y.begin(),Y.end());
SIZES=Y;
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;
}
/*
int main()
{
cout<<putaway(3,2,10,{6,2,9},{4,7},{4,8,2,7,1,5,3,8,7,10},{6,5,3,9,8,1,3,7,6,5})<<endl;
}
*/