Submission #1074019

#TimeUsernameProblemLanguageResultExecution timeMemory
1074019Gromp15Radio Towers (IOI22_towers)C++17
0 / 100
4098 ms2096 KiB
#include <bits/stdc++.h> #include "towers.h" #define ll long long #define ar array #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() using namespace std; template<typename T> bool ckmin(T &a, const T &b ) { return a > b ? a = b, 1 : 0; } template<typename T> bool ckmax(T &a, const T &b ) { return a < b ? a = b, 1 : 0; } int N; vector<int> h; void init(int _N, std::vector<int> H) { N = _N; h = H; } int max_towers(int L, int R, int D) { auto solve = [&](auto&& s, int l, int r, int lim) -> int { if (l > r) return 0; if (l == r) return h[l] <= lim; int p = -1; for (int i = l; i <= r; i++) if (h[p] <= lim && (!~p || h[i] > h[p])) p = i; if (!~p) return 0; return max(int(h[p] <= lim), s(s, l, p-1, h[p] - D) + s(s, p+1, r, h[p] - D)); }; return solve(solve, L, R, 1e9); }
#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...