Submission #104849

#TimeUsernameProblemLanguageResultExecution timeMemory
104849popovicirobertRobots (IOI13_robots)C++14
0 / 100
3 ms404 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; struct Comp { int val, pos; bool operator <(const Comp &other) const { if(val == other.val) return pos < other.pos; return val < other.val; } }; inline bool check(int res, int A, int B, int T, int X[], int Y[], int W[], int S[]) { vector <int> ord(T); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](const int &a, const int &b) {return W[a] < W[b];}); multiset <Comp> mst; vector <bool> vis(T); int pos = 0, ans = 0; for(int i = 0; i < A; i++) { while(pos < T && W[ord[pos]] < X[i]) { mst.insert({S[ord[pos]], ord[pos]}); pos++; } for(int j = 1; j <= res && mst.size(); j++) { auto it = prev(mst.end()); vis[it -> pos] = 1; mst.erase(it); ans++; } } sort(ord.begin(), ord.end(), [&](const int &a, const int &b) {return S[a] < S[b];}); pos = 0; int cnt = 0; for(int i = 0; i < B; i++) { while(pos < T && S[ord[pos]] < Y[i]) { if(vis[ord[pos]] == 0) { cnt++; } pos++; } for(int j = 1; j <= res && cnt > 0; j++) { ans++; cnt--; } } return ans == T; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { int res = 0; for(int step = 1 << 20; step; step >>= 1) { if(!check(res + step, A, B, T, X, Y, W, S)) { res += step; } } res++; return check(res, A, B, T, X, Y, W, S) ? res : -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...