Submission #735894

#TimeUsernameProblemLanguageResultExecution timeMemory
735894math_rabbit_1028Radio Towers (IOI22_towers)C++17
0 / 100
672 ms2120 KiB
#include "towers.h" #include <bits/stdc++.h> using namespace std; int n; vector<int> arr; vector<int> upidx, downidx; vector<int> dvalues; void init(int N, vector<int> H) { n = N; for (int i = 0; i < N; i++) arr.push_back(H[i]); if (arr[0] < arr[1]) downidx.push_back(0); for (int i = 1; i < N - 1; i++) { if (arr[i] > arr[i - 1] && arr[i] > arr[i + 1]) upidx.push_back(i); if (arr[i] < arr[i - 1] && arr[i] < arr[i + 1]) downidx.push_back(i); } if (arr[N - 1] < arr[N - 2]) downidx.push_back(N - 1); assert(downidx.size() == upidx.size() + 1); for (int i = 0; i < upidx.size(); i++) { dvalues.push_back(arr[upidx[i]] - max(arr[downidx[i]], arr[downidx[i + 1]])); } sort(dvalues.begin(), dvalues.end()); } int max_towers(int L, int R, int D) { int ans = dvalues.end() - lower_bound(dvalues.begin(), dvalues.end(), D) + 1; return ans; }

Compilation message (stderr)

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:21:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   for (int i = 0; i < upidx.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~
#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...