Submission #587104

#TimeUsernameProblemLanguageResultExecution timeMemory
587104FatihSolakRobots (IOI13_robots)C++17
76 / 100
3065 ms28704 KiB
#include "robots.h" #include <bits/stdc++.h> #define N 1000005 using namespace std; vector<int> x,y; vector<pair<int,int>> toys; int a,b,t; int cnt[N]; bool ck(int x){ multiset<int> rem; for(int i = 0;i<t;i++){ rem.insert(toys[i].second); long long val = (long long)cnt[i] * x; while(val && rem.size()){ val--; rem.erase(prev(rem.end())); } } for(int i = b-1;i>=0;i--){ int val = x; while(val && rem.size() && *rem.begin() < y[i]){ val--; rem.erase(prev(rem.lower_bound(y[i]))); } } return rem.empty(); } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]){ x.push_back(1); y.push_back(1); for(int i = 0;i<A;i++){ x.push_back(X[i]); } for(int i = 0;i<B;i++){ y.push_back(Y[i]); } for(int i = 0;i<T;i++){ toys.push_back({W[i],S[i]}); } a = A+1; b = B+1; t = T; sort(x.begin(),x.end()); sort(y.begin(),y.end()); sort(toys.begin(),toys.end()); for(auto u:toys){ if(u.first >= x.back() && u.second >= y.back()){ return -1; } } int pt = 0; for(auto u:x){ while(pt < t && toys[pt].first < u){ pt++; } if(pt) cnt[pt-1]++; } int l = 1,r = t; while(l < r){ int m = (l+r)/2; if(ck(m)){ r = m; } else l = m+1; } return l; }
#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...