Submission #625468

#TimeUsernameProblemLanguageResultExecution timeMemory
625468model_codeRadio Towers (IOI22_towers)C++17
11 / 100
4074 ms1516 KiB
// time_limit/solution-quadratic.cpp #include "towers.h" #include <bits/stdc++.h> using namespace std; int N; vector<int> H; vector<bool> used; void init(int _N, std::vector<int> _H) { N = _N; H = _H; used.resize(N); } int max_towers(int L, int R, int D) { vector<int> towers(R - L + 1); iota(towers.begin(), towers.end(), L); sort(towers.begin(), towers.end(), [&] (int i, int j) { return H[i] < H[j]; }); fill(used.begin() + L, used.begin() + R + 1, false); for (int i : towers) { bool can_use = true; for (int dir : {-1, 1}) { for (int j = i + dir; L <= j && j <= R && can_use; j += dir) { if (H[i] <= H[j] - D) { break; } if (used[j]) { can_use = false; } } } if (can_use) { used[i] = true; } } return count(used.begin() + L, used.begin() + R + 1, true); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...