Submission #892656

#TimeUsernameProblemLanguageResultExecution timeMemory
892656Trisanu_DasRadio Towers (IOI22_towers)C++17
27 / 100
4086 ms1852 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> h; void init(int N, vector<int> H) { n = N, h = H; } int max_towers(int L, int R, int D) { int ans = 0, m = 2e9; bool inter = true; for (int i = L; i <= R; ++i) { if (!inter) { if (h[i] < m) m = h[i]; else if (h[i] - D >= m) inter = true, m = h[i]; } else { if (h[i] > m) m = h[i]; else if (m - D >= h[i]) inter = false, ans++, m = h[i]; } } return ans; }
#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...