Submission #307223

#TimeUsernameProblemLanguageResultExecution timeMemory
307223quocnguyen1012Robots (IOI13_robots)C++14
100 / 100
1000 ms18724 KiB
#ifndef LOCAL #include"robots.h" #endif // LOCAL #include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define pb push_back #define eb emplace_back #define ar array using namespace std; typedef long long ll; typedef pair<int, int> ii; const int maxn = 2e5 + 5; vector<int> query[maxn]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { sort(X, X + A); sort(Y, Y + B); int n = A + B; for(int i = 0; i < T; ++i){ int l = upper_bound(X, X + A, W[i]) - X; int r = upper_bound(Y, Y + B, S[i]) - Y; r = B - r - 1; r += A; query[l].eb(r); if (l > r) { return -1; } } auto check = [&](int mx) { priority_queue<int, vector<int>, greater<int>> pq; for(int l = 0; l < n; ++l){ for(int r : query[l]) pq.push(r); for(int i = 0; i < mx; ++i){ if(pq.empty()) break; if(pq.top() < l) return false; pq.pop(); } } return pq.empty(); }; if(!check(T)) return -1; int l = 1, r = T, mid; while(l <= r){ mid = (l + r) / 2; if(!check(mid)) l = mid + 1; else r = mid - 1; } return l; } #ifdef LOCAL signed main(void) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LOCAL freopen("A.INP", "r", stdin); freopen("A.OUT", "w", stdout); #endif // LOCAL int A, B, T; cin >> A >> B >> T; int X[A], Y[B], W[T], S[T]; for(int i = 0; i < A; ++i) cin >> X[i]; for(int i = 0; i < B; ++i) cin >> Y[i]; for(int i = 0; i < T; ++i) cin >> W[i]; for (int i = 0; i < T; ++i) cin >> S[i]; cout << putaway(A, B, T, X, Y, W, S); } #endif
#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...