Submission #1059424

#TimeUsernameProblemLanguageResultExecution timeMemory
1059424vjudge1Robots (IOI13_robots)C++17
53 / 100
177 ms18868 KiB
#include "robots.h" #include<bits/stdc++.h> #define ll long long using namespace std; vector<pair<int,int>> Tw,Ts; int a, b, t; vector<int> x, y; bool bcheck(int n){ int pos=0,cnt=n,toys_cnt1=0,toys_cnt2=0; vector<bool> Tbool1(t,0), Tbool2(t,0); if(a != 0){ for(int i=0; i < t; i++){ if(Tw[i].first < x[pos]){ cnt--; toys_cnt1++; Tbool1[Tw[i].second] = 1; } if(cnt == 0){ cnt = n; pos++; } if(pos >= a)break; } if(b == 0)return toys_cnt1 == t; pos = 0; cnt = n; for(int i=0; i < t; i++){ if(Ts[i].first < y[pos] && !Tbool1[Ts[i].second]){ cnt--; toys_cnt1++; Tbool1[Ts[i].second] = 1; } if(cnt == 0){ cnt = n; pos++; } if(pos >= b)break; } } if(b != 0){ pos = 0; cnt = n; for(int i=0; i < t; i++){ if(Ts[i].first < y[pos]){ cnt--; toys_cnt2++; Tbool2[Ts[i].second] = 1; } if(cnt == 0){ cnt = n; pos++; } if(pos >= b)break; } if(a == 0)return toys_cnt2 == t; pos = 0; cnt = n; for(int i=0; i < t; i++){ if(Tw[i].first < x[pos] && !Tbool2[Tw[i].second]){ cnt--; toys_cnt2++; Tbool2[Tw[i].second] = 1; } if(cnt == 0){ cnt = n; pos++; } if(pos >= a)break; } } return toys_cnt1 == t || toys_cnt2 == t; } int binary(int l, int r){ int n; while(l <= r){ n = (l+r)/2; if(bcheck(n)){ r = n-1; }else{ l = n+1; } } return l; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int ans=-1; a = A; b = B; t = T; for(int i=0; i < A; i++){ x.push_back(X[i]); } sort(x.rbegin(),x.rend()); for(int i=0; i < B; i++){ y.push_back(Y[i]); } sort(y.rbegin(),y.rend()); for(int i=0; i < T; i++){ Tw.push_back({W[i],i}); Ts.push_back({S[i],i}); } sort(Tw.rbegin(),Tw.rend()); sort(Ts.rbegin(),Ts.rend()); ans=binary(1,T); if(ans > T)ans = -1; return ans; }
#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...