Submission #1072985

#TimeUsernameProblemLanguageResultExecution timeMemory
1072985ZicrusRadio Towers (IOI22_towers)C++17
27 / 100
4096 ms1604 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; typedef long long ll; 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 res = 1; int mn = 1 << 30, mx = 0; bool foundK = false; for (int i = L; i <= R; i++) { if (!foundK) { if (h[i] >= mn+D) { foundK = true; mx = h[i]; continue; } mn = min(mn, h[i]); } else { if (h[i] <= mx-D) { foundK = false; res++; mn = h[i]; continue; } mx = max(mx, h[i]); } } 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...