Submission #242649

#TimeUsernameProblemLanguageResultExecution timeMemory
242649HynDufRobots (IOI13_robots)C++14
0 / 100
3075 ms17020 KiB
#include <bits/stdc++.h> #include "robots.h" #define task "R" #define all(v) (v).begin(), (v).end() #define rep(i, l, r) for (int i = (l); i <= (r); ++i) #define Rep(i, r, l) for (int i = (r); i >= (l); --i) #define DB(X) { cerr << #X << " = " << (X) << '\n'; } #define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; } #define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; } #define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; } #define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';} #define SZ(x) ((int)(x).size()) #define pb push_back #define eb emplace_back #define pf push_front #define F first #define S second #define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a)); #define next ___next #define prev ___prev #define y1 ___y1 #define left ___left #define right ___right #define y0 ___y0 #define div ___div #define j0 ___j0 #define jn ___jn using ll = long long; using ld = long double; using ull = unsigned long long; using namespace std; typedef pair<int, int> ii; typedef pair<ii, int> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<ll> vl; const int N = 5e4 + 1; int bnd[N]; int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) { vii rob; rep(i, 0, T - 1) rob.eb(W[i], S[i]); sort(all(rob)); sort(X, X + A); sort(Y, Y + B); rep(i, 0, A - 1) bnd[i] = upper_bound(all(rob), ii(X[i] - 1, 2e9)) - rob.begin() - 1; int l = 1, r = 2e9; priority_queue<ii> pq; while (l <= r) { int m = (l + r) >> 1; priority_queue<ii> pq; bool ok = 1; int lstj = 0; rep(i, 0, A - 1) { rep(j, lstj, bnd[i]) pq.push(ii(rob[j].S, rob[j].F)); lstj = bnd[i] + 1; rep(j, 1, m) { if (pq.empty()) break; pq.pop(); } } rep(j, lstj, T - 1) pq.push(ii(rob[j].S, rob[j].F)); Rep(i, B - 1, 0) { rep(j, 1, m) { if (pq.empty()) break; if (Y[i] <= pq.top().F) { ok = 0; break; } pq.pop(); } } if (!pq.empty()) ok = 0; if (ok) r = m - 1; else l = m + 1; } return l; } /* int xx[] = {6, 2, 9}, yy[] = {4, 7}, w[] = {4, 8, 2, 7, 1, 5, 3, 8, 7, 10}, s[] = {6, 5, 3, 9, 8, 1, 3, 7, 6, 5}; int main() { #ifdef HynDuf freopen(task".in", "r", stdin); //freopen(task".out", "w", stdout); #else ios_base::sync_with_stdio(false); cin.tie(nullptr); #endif cout << putaway(3, 2, 10, xx, yy, w, s); return 0; } */
#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...