Submission #812168

#TimeUsernameProblemLanguageResultExecution timeMemory
812168kwongwengRadio Towers (IOI22_towers)C++17
18 / 100
787 ms2484 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<ii> vii; typedef long double ld; typedef pair<ll, ll> pll; #define FOR(i, a, b) for(int i = a; i < b; i++) #define ROF(i, a, b) for(int i = a; i >= b; i--) #define ms memset #define pb push_back #define fi first #define se second int k, n; vi h; vi cnt(1e5), pre(1e5); void init(int N, vi H) { n=N; h=H; FOR(i,1,n-1){ if (H[i]>max(H[i-1],H[i+1])){ k=i; cnt[i]++; } } pre[0]=cnt[0]; FOR(i,1,n) pre[i]=pre[i-1]+cnt[i]; } int max_towers(int L, int R, int D) { if (R-L<=1) return 1; if (D==1){ return pre[R-1] - pre[L] + 1; } if (L>=k || R<=k) return 1; if (max(h[L],h[R]) > h[k]-D) return 1; return 2; }
#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...