Submission #626142

#TimeUsernameProblemLanguageResultExecution timeMemory
626142Clan328Radio Towers (IOI22_towers)C++17
11 / 100
4075 ms1464 KiB
#include "towers.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define nL '\n' #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() typedef long long ll; typedef long double ld; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pii> vpii; typedef vector<ll> vl; typedef vector<vl> vvl; typedef pair<ll, ll> pll; typedef vector<pll> vpll; const ll MOD = 1e9 + 7; void eval(bool condition) { cout << (condition ? "yes" : "no") << nL; } void Eval(bool condition) { cout << (condition ? "Yes" : "No") << nL; } int ipow(int a, int n) { if (n == 0) return 1; int x = ipow(a, n/2); if (n % 2 == 0) return x*x; return x*x*a; } template <typename T> ostream& operator<<(ostream& stream, const vector<T>& v) { for (auto elem : v) stream << elem << " "; return stream; } template <typename T> istream& operator>>(istream& stream, vector<T>& v){ for(auto &elem : v) stream >> elem; return stream; } int n; vi heights; void init(int N, std::vector<int> H) { n = N; heights = H; } int max_towers(int L, int R, int D) { vi dp(n, 1); int res = 0; for (int i = L; i <= R; i++) { int tower = heights[i-1]; for (int j = i-2; j >= L; j--) { if (tower-D >= heights[i] && tower-D >= heights[j]) dp[i] = max(dp[i], dp[j]+1); tower = max(tower, heights[j]); } res = max(dp[i], res); } return res; }
#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...