제출 #425192

#제출 시각아이디문제언어결과실행 시간메모리
425192pliam로봇 (IOI13_robots)C++14
100 / 100
2553 ms24308 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; vector<pair<int,int>> toys;//(weight,size) int a,b,t; int* x; int* y; bool check(int s){ int pos=0; priority_queue<int> q;//with size for(int i=0;i<a;i++){ while(pos<t && toys[pos].first<x[i]){ q.push(toys[pos].second); pos++; } int cnt=0; while(!q.empty() && cnt<s){ q.pop();//it goes to weak robot i cnt++; } } //put the remaining to small robots in the same way while(pos<t){ q.push(toys[pos].second); pos++; } for(int i=b-1;i>=0 && !q.empty();i--){ int cnt=0; if(q.top()>=y[i]) return false; while(!q.empty() && cnt<s){ q.pop(); cnt++; } } return q.empty()?true:false; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X,X+A); sort(Y,Y+B); for(int i=0;i<T;i++){ toys.push_back({W[i],S[i]}); } sort(toys.begin(),toys.end()); x=X; y=Y; a=A; b=B; t=T; //binary search int k=T; for(int bima=T;bima>0;bima/=2){ while(k-bima>=0&&check(k-bima)) k-=bima; } return check(k)?k:-1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...