Submission #689638

#TimeUsernameProblemLanguageResultExecution timeMemory
689638lohachoRadio Towers (IOI22_towers)C++17
11 / 100
4042 ms8184 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> a; void init(int N, std::vector<int> H) { n = N; a = H; } int max_towers(int L, int R, int D) { vector<vector<int>> srt; for(int i = L; i <= R; ++i){ srt.push_back({a[i], i}); } sort(srt.begin(), srt.end()); vector<int> chk(n); for(int i = 0; i < (int)srt.size(); ++i){ int now = srt[i][1]; if(now < L || now > R){ continue; } int r = now + 1, can = 1; while(r <= R && a[r] < a[now] + D){ if(chk[r]){ can = 0; break; } ++r; } int l = now - 1; while(l >= L && a[l] < a[now] + D){ if(chk[l]){ can = 0; break; } --l; } chk[now] = can; } return accumulate(chk.begin(), chk.end(), 0ll); }
#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...