Submission #1164652

#TimeUsernameProblemLanguageResultExecution timeMemory
1164652SmuggingSpunRadio Towers (IOI22_towers)C++20
0 / 100
202 ms8828 KiB
#include "towers.h" #include<bits/stdc++.h> using namespace std; const int lim = 1e5 + 5; template<class T>void maximize(T& a, T b){ if(a < b){ a = b; } } int n, k, log_v[lim], h[lim], pref[lim], spt[lim][17]; void init(int N, vector<int>H) { n = N; log_v[0] = -1; for(int i = 0; i < n; i++){ spt[i + 1][0] = h[i + 1] = H[i]; log_v[i + 1] = log_v[(i + 1) >> 1] + 1; } for(int j = 1; j < 17; j++){ for(int i = 1; i + (1 << j) - 1 <= n; i++){ spt[i][j] = max(spt[i][j - 1], spt[i + (1 << (j - 1))][j - 1]); } } spt[0][0] = spt[n + 1][0] = INT_MAX; pref[0] = 0; for(int i = 1; i <= n; i++){ pref[i] = pref[i - 1] + int(spt[i][0] < spt[i - 1][0] && spt[i][0] < spt[i + 1][0]); } } int get_max(int l, int r){ int k = log_v[r - l + 1]; return max(spt[l][k], spt[r - (1 << k) + 1][k]); } int max_towers(int l, int r, int d){ return pref[r + 1] - pref[l]; }
#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...