Submission #723058

# Submission time Handle Problem Language Result Execution time Memory
723058 2023-04-13T08:01:20 Z josanneo22 Radio Towers (IOI22_towers) C++17
Compilation error
0 ms 0 KB
//#include "towers.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int mx=-1;
vector<int> h;
void init(int N, std::vector<int> H) {
	h=H;
	for(int i=1;i<N-1;i++){
		if(h[i]>h[i-1] && h[i]>h[i+1]) mx=i;
	}
}

int max_towers(int L, int R, int D) {
  int l=L,r=R;
	if(l>=mx || r<=mx) return 1;
	else{
		if(h[l]+D<=h[mx] && h[r]+D<=h[mx]) return 2;
		else return 1;
	}
}

#include <cassert>
#include <cstdio>

#include <vector>

int main() {
  int N, Q;
  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));
    printf("%d\n", max_towers(L, R, D));
  }
  return 0;
}

Compilation message

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