Submission #373782

#TimeUsernameProblemLanguageResultExecution timeMemory
373782moratoRobots (IOI13_robots)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #include "robots.h" using namespace std; const int N = 1e6 + 5; const int M = 5e5 + 5; const int INF = 1e9; int a, b, t, x[M], y[M], limite[M], ans; pair<int, int> toys[N]; bool check(int qtd) { int ptr = 0; priority_queue<pair<int, int>> pq; for (int i = 0; i < a; i++) { while (ptr < limite[i]) { pq.emplace(toys[ptr].second, toys[ptr].first); ptr++; } int cnt = 0; while (!pq.empty() && cnt < qtd) { pq.pop(); cnt++; } } for (; ptr < t; ptr++) { pq.emplace(toys[ptr].second, toys[ptr].first); } for (int i = 0; i < b; i++) { int cnt = 0; while (!pq.empty() && pq.top().first < y[i] && cnt < qtd) { pq.pop(); cnt++; } } return pq.empty(); } void solve() { sort(toys, toys + t); for (int i = 0; i < a; i++) { limite[i] = lower_bound(toys, toys + t, pair<int, int>(x[i], -1)) - toys; cout << limite[i] << '\n'; } sort(y, y + b, greater<int>()); int l = 1, r = 1e6, best = -1; while (l <= r) { int m = (l + r) >> 1; if (check(m)) { best = m; r = m - 1; } else { l = m + 1; } } ans = best; } int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { a = A, b = B, t = T; for (int i = 0; i < a; i++) { x[i] = X[i]; } for (int i = 0; i < b; i++) { y[i] = Y[i]; } for (int i = 0; i < t; i++) { toys[i] = {W[i], S[i]}; } solve(); 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...