Submission #735893

# Submission time Handle Problem Language Result Execution time Memory
735893 2023-05-05T00:46:41 Z math_rabbit_1028 Radio Towers (IOI22_towers) C++17
0 / 100
15 ms 4000 KB
#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]) upidx.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

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 time Memory Grader output
1 Runtime error 11 ms 2072 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 15 ms 4000 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 1232 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '131'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 11 ms 2072 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -