Submission #729635

#TimeUsernameProblemLanguageResultExecution timeMemory
729635NeroZein로봇 (IOI13_robots)C++17
0 / 100
1 ms340 KiB
#include "robots.h" #include <bits/stdc++.h> using namespace std; const int N = 50004; const int T = 1000006; int x[T], y[T]; int w[T], s[T]; int putaway(int A, int B, int T_, int X[], int Y[], int W[], int S[]) { int a, b, t; 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) { w[i] = W[i], s[i] = S[i]; } vector<pair<int, int>> toy(t); for (int i = 0; i < t; ++i) { toy[i] = {w[i], s[i]}; } sort(toy.begin(), toy.end(), greater<pair<int, int>>()); auto ch = [&](int mid) { set<pair<int, int>> sx; set<pair<int, int>> se; for (int i = 0; i < b; ++i) { se.emplace(y[i], mid); } for (int i = 0; i < a; ++i) { sx.emplace(x[i], mid); } for (int i = 0; i < t; ++i) { pair<int, int> pp = make_pair(toy[i].second, 2e9); auto it = se.upper_bound(pp); if (it != se.end()) { auto it2 = *it; //cout << "Se is: "; for (auto j : se) cout << j.first << ' ' << j.second << ", "; cout << '\n'; se.erase(it); it2.second--; if (it2.second != 0) { se.emplace(it2); } //cout << "robSmall: " << ' ' << it2.first << ' ' << it2.second << " SzToy: " << toy[i].second << '\n'; } else { pp = make_pair(toy[i].first, 2e9); it = sx.upper_bound(pp); if (it == sx.end()) { return false; } //cout << "Sx is: "; for (auto j : sx) cout << j.first << ' ' << j.second << ", "; cout << '\n'; sx.erase(it); auto it2 = *it; it2.second--; //cout << "robWeak: " << ' ' << it2.first << ' ' << it2.second << " WeighToy: " << toy[i].first << '\n'; if (it2.second != 0) { sx.emplace(it2); } } } //cout << '\n'; return true; }; int l = 1, r = t + 1; while (l < r) { int mid = (l + r) >> 1; if (ch(mid)) { r = mid; } else { l = mid + 1; } } return (l == t + 1 ? -1 : l); }
#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...