Submission #1056691

#TimeUsernameProblemLanguageResultExecution timeMemory
1056691DorostWefRadio Towers (IOI22_towers)C++17
0 / 100
9 ms2136 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; const int N = 2002; int h[N]; bool f[N]; int n; void init(int N, std::vector<int> H) { n = N; for (int i = 0; i < n; i++) h[i] = H[i]; } int solve (int l, int r, int d) { if (l > r) return 0; if (l == r) return f[l]; int mx = -1, in = -1; for (int i = l; i <= r; i++) { if (h[i] > mx) { mx = h[i]; in = i; } } int fin = (int)f[in]; //if (f[in]) { for (int i = l; i <= r; i++) { if (h[i] > mx - d) f[i] = false; } //} return max (fin, solve (l, in - 1, d) + solve(in + 1, r, d)); } int max_towers(int L, int R, int D) { for (int i = 0; i < N; i++) f[i] = true; return max (1, solve (L, R, D)); }
#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...