답안 #735892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
735892 2023-05-05T00:44:17 Z math_rabbit_1028 송신탑 (IOI22_towers) C++17
0 / 100
624 ms 2076 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);
  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:20:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |   for (int i = 0; i < upidx.size(); i++) {
      |                   ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 407 ms 1104 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 624 ms 2076 KB 1st lines differ - on the 1st token, expected: '11903', found: '33011'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 6 ms 1232 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 407 ms 1104 KB 1st lines differ - on the 1st token, expected: '1', found: '2'
2 Halted 0 ms 0 KB -