Submission #799950

#TimeUsernameProblemLanguageResultExecution timeMemory
799950adrilenRadio Towers (IOI22_towers)C++17
0 / 100
10 ms1872 KiB
#include "towers.h" //#pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; using ll = long long; using arr = array<int, 2>; using arrr = array<int, 3>; constexpr int maxn = 1e5 + 5; int n; int pref[maxn] = { 0 }; int h[maxn] = { 0 }; void init(int N, std::vector<int> H) { n = N; for (int i = 0; i < n; i++) h[i] = H[i]; if (n < 3) return ; if (H[0] < H[1]) pref[0] ++; for( int i = 1; i < n - 1;i++) pref[i] += (H[i - 1] > H[i] && H[i] < H[i + 1]); if (H[n - 1] < H[n - 2]) pref[n - 1]++; for (int i = 1; i < n; i++) pref[i] += pref[i - 1]; for (int i = 0; i < n; i++) cout << pref[i] << " "; cout << "\n"; } int max_towers(int L, int R, int D) { if (R - L < 2) return 1; int output = pref[R] - (L != 0 ? pref[L - 1] : 0); if (L != 0 && pref[L] == pref[L - 1]) output += (h[L] < h[L + 1]); if (R != n - 1 && pref[R] == pref[R - 1]) output += (h[R] < h[R - 1]); return output; }
#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...