Submission #652679

#TimeUsernameProblemLanguageResultExecution timeMemory
652679BlagojRadio Towers (IOI22_towers)C++17
0 / 100
639 ms2212 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; vector<int> h; int f[100009], p[100009]; bool used[100009]; void init(int N, std::vector<int> H) { h = H; f[0] = 1000000009; f[N + 1] = 0; for (int i = 1; i <= N; i++) { f[i] = H[i - 1]; } p[0] = 0; for (int i = 1; i <= N; i++) { p[i] = p[i - 1]; if (f[i - 1] > f[i] && f[i + 1] > f[i]) { p[i]++; used[i] = true; } } } int max_towers(int L, int R, int D) { L++; R++; int ans = p[R] - p[L - 1]; if (!used[L] && f[L - 1] > f[L]) { ans++; } if (L != R && !used[R] && f[R + 1] > f[R]) { ans++; } return max(ans, 1); }
#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...