Submission #735145

#TimeUsernameProblemLanguageResultExecution timeMemory
735145math_rabbit_1028Radio Towers (IOI22_towers)C++17
11 / 100
4072 ms2840 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> arr; int sort_index[101010]; void init(int N, vector<int> H) { n = N; vector< pair<int, int> > temp; for (int i = 0; i < N; i++) arr.push_back(H[i]); for (int i = 0; i < N; i++) temp.push_back({H[i], i}); sort(temp.begin(), temp.end()); for (int i = 0; i < N; i++) { sort_index[i] = temp[i].second; } } int ch[101010]; int max_towers(int L, int R, int D) { int ans = 0; for (int i = 0; i < n; i++) ch[i] = 0; for (int i = 0; i < n; i++) { if (sort_index[i] < L || sort_index[i] > R) continue; bool f = true; int maxval = 0; for (int j = sort_index[i] + 1; j <= R; j++) { if (ch[j] == 1) { if (maxval < max(arr[sort_index[i]], arr[j]) + D) f = false; break; } maxval = max(maxval, arr[j]); } maxval = 0; for (int j = sort_index[i] - 1; j >= L; j--) { if (ch[j] == 1) { if (maxval < max(arr[sort_index[i]], arr[j]) + D) f = false; break; } maxval = max(maxval, arr[j]); } if (f) { ans++; ch[sort_index[i]] = 1; } } 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...