Submission #627178

#TimeUsernameProblemLanguageResultExecution timeMemory
627178typ_ikRadio Towers (IOI22_towers)C++17
27 / 100
4070 ms1484 KiB
#include <bits/stdc++.h> using namespace std; int n; vector <int> h; void init(int N, vector<int> H) { n = N; h = H; } int max_towers(int L, int R, int D) { bool has = true; int lst = 2e9; int ans = 0; for (int i = L; i <= R; i++) { if (has) { if (lst < h[i]) lst = max(lst, h[i]); else if (h[i] <= lst - D) { has = false; lst = h[i]; ans++; } } else { if (lst > h[i]) lst = min(lst, h[i]); else if (h[i] - D >= lst) { has = true; lst = h[i]; } } } return ans; } //main() { // vector <int> cur = {10, 20, 60, 40, 50, 30, 70}; // init((int) cur.size(), cur); // cout << max_towers(1, 5, 10) << '\n'; // cout << max_towers(2, 2, 10) << '\n'; // cout << max_towers(0, 6, 17) << '\n'; //}
#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...