Submission #764115

#TimeUsernameProblemLanguageResultExecution timeMemory
764115dxz05Radio Towers (IOI22_towers)C++17
23 / 100
4091 ms9036 KiB
#pragma GCC optimize("Ofast,O3,unroll-loops") #pragma GCC target("avx,avx2") #include "towers.h" #include <bits/stdc++.h> using namespace std; vector<int> a; void init(int N, vector<int> H) { a = H; } int calc(int l, int r, int h, int d){ if (l > r) return 0; if (r - l + 1 <= 2) return a[l] <= h || a[r] <= h; int ans = 0; int m = l; for (int i = l; i <= r; i++){ if (a[i] > a[m]) m = i; if (a[i] <= h) ans = 1; } ans = max(ans, calc(l, m - 1, a[m] - d, d) + calc(m + 1, r, a[m] - d, d)); return ans; } int max_towers(int L, int R, int D) { return calc(L, R, 2e9, 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...