Submission #298184

#TimeUsernameProblemLanguageResultExecution timeMemory
298184williamMBDKRobots (IOI13_robots)C++11
28 / 100
296 ms8696 KiB
#include<bits/stdc++.h> using namespace std; #include "robots.h" vector<int> xs, ys, as, bs; int solveb(int A, int B, int T, int X[], int Y[], int W[], int S[]) { as = vector<int> (A), bs = vector<int> (B), xs = vector<int> (T), ys = vector<int> (T); for(int i = 0; i < T; i++) xs[i] = W[i]; //cout << xs[i] << " "; for(int i = 0; i < T; i++) ys[i] = S[i]; for(int i = 0; i < A; i++) as[i] = X[i]; //cout << i << " " << as[i] << " "; for(int i = 0; i < B; i++) bs[i] = Y[i]; sort(xs.begin(), xs.end()); sort(ys.begin(), ys.end()); sort(as.begin(), as.end()); sort(bs.begin(), bs.end()); if(A == 0 || xs[T-1] >= as[A-1]) return -1; int res = 0; priority_queue<int> q; for(int i = T - 1; i >= 0; i--){ if(q.empty()) q.push(A-1), res++; auto t = q.top(); q.pop(); if(xs[i] >= as[t]){ q.push(t); if(A > 1) q.push(A-2); res++; }else if(t > 0) q.push(t-1); } return res; } int solvea(int A, int B, int T, int X[], int Y[], int W[], int S[]) { as = vector<int> (A), bs = vector<int> (B), xs = vector<int> (T), ys = vector<int> (T); for(int i = 0; i < T; i++) xs[i] = W[i]; //cout << xs[i] << " "; for(int i = 0; i < T; i++) ys[i] = S[i]; for(int i = 0; i < A; i++) as[i] = X[i]; //cout << i << " " << as[i] << " "; for(int i = 0; i < B; i++) bs[i] = Y[i]; sort(xs.begin(), xs.end()); sort(ys.begin(), ys.end()); sort(as.begin(), as.end()); sort(bs.begin(), bs.end()); pair<int,int> m1 = {W[0], S[0]}; pair<int,int> m2 = {W[1], S[1]}; if(A == 2){ if(as[1] > xs[1] && as[0] > xs[0]) return 1; else if(as[1] > xs[1]) return 2; return -1; }else if(B == 2){ if(bs[1] > ys[1] && bs[0] > ys[0]) return 1; else if(bs[1] > ys[1]) return 2; return -1; }else{ if(as[0] > m1.first && bs[0] > m2.second) return 1; else if(as[0] > m2.first && bs[0] > m1.second) return 1; else if(as[0] > m2.first && as[0] > m1.first) return 2; else if(bs[0] > m2.second && bs[0] > m1.second) return 2; return -1; } } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { if(B == 0) return solveb(A, B, T, X, Y, W, S); return solvea(A, B, T, X, Y, W, S); }
#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...