Submission #1056212

#TimeUsernameProblemLanguageResultExecution timeMemory
1056212parsadox2Radio Towers (IOI22_towers)C++17
11 / 100
7 ms2136 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; const int N = 2e3 + 10 , inf = 1e9; int n , a[N]; void init(int nn , vector <int> vec) { n = nn; for(int i = 0 ; i < n ; i++) a[i] = vec[i]; } int Solve(int l , int r , int d , int val) { if(l > r) return 0; int mn = inf; int pos_mx = l; for(int i = l ; i <= r ; i++) { mn = min(mn , a[i]); if(a[i] > a[pos_mx]) pos_mx = i; } if(mn > val) return 0; int res = max(1 , Solve(l , pos_mx - 1 , d , a[pos_mx] - d) + Solve(pos_mx + 1 , r , d , a[pos_mx] - d)); return res; } int max_towers(int l , int r , int d) { return Solve(l , r , d , inf); }
#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...