Submission #763534

#TimeUsernameProblemLanguageResultExecution timeMemory
763534drdilyorRadio Towers (IOI22_towers)C++17
23 / 100
4090 ms1872 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; using ll = long long; int n; vector<int> h, ix; void init(int N, std::vector<int> H) { n = N, h = H; ix.resize(n); iota(ix.begin(), ix.end(), 0); sort(ix.begin(), ix.end(), [&](int i, int j) { return h[i] < h[j]; }); } int max_towers(int L, int R, int D) { int res = 0; for (int i_ = 0; i_ < n; i_++) { int i = ix[i_]; if (i < L || i > R) continue; bool ok = 1; for (int j = i; j >= L; j--) { if (h[j] < h[i]) { ok = 0; break; } else if (h[j] - h[i] >= D) break; } for (int j = i; j <= R; j++) { if (h[j] < h[i]) {ok = 0;break;} else if (h[j] - h[i] >= D) break; } res += ok; } return res; }
#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...