답안 #824230

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
824230 2023-08-13T19:32:38 Z Liudas 송신탑 (IOI22_towers) C++17
컴파일 오류
0 ms 0 KB
#include "towers.h"

#include <cassert>
#include <cstdio>

#include <bits/stdc++.h>
using namespace std;
vector<int> h;
void init(int N, vector<int> H){
    h = H;
}
int max_towers(int L, int R, int D){
    int score = 0;
    for(int i = L; i <= R; i ++){
        int H = h[i];
        int s = 0;
        bool good = false;
        for(int j = L; j <= R; j ++){
            if(!good && h[j] + D <= H){
                s ++;
                good = true;
            }
            else if(good && h[j] >= H){
                good = false;
            }
        }
        score = max(score, s);
    }
    return max(1, score);
}
int main() {
  int N, Q;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  assert(2 == scanf("%d %d", &N, &Q));
  std::vector<int> H(N);
  for (int i = 0; i < N; ++i) {
    assert(1 == scanf("%d", &H[i]));
  }
  init(N, H);

  for (int i = 0; i < Q; ++i) {
    int L, R, D;
    assert(3 == scanf("%d %d %d", &L, &R, &D));
    cout << max_towers(L, R, D) << "\n";
  }
  return 0;
}

Compilation message

/usr/bin/ld: /tmp/cckFdXNP.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccWLVRiQ.o:towers.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status