Submission #723056

# Submission time Handle Problem Language Result Execution time Memory
723056 2023-04-13T07:59:26 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[k]>h[k-1] && h[i]>h[i+1]) mx=i;
	}
}

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

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:10:8: error: 'k' was not declared in this scope
   10 |   if(h[k]>h[k-1] && h[i]>h[i+1]) mx=i;
      |        ^
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:15:5: error: 'l' was not declared in this scope
   15 |  if(l>=mx || r<=mx) return 1;
      |     ^
towers.cpp:15:14: error: 'r' was not declared in this scope
   15 |  if(l>=mx || r<=mx) return 1;
      |              ^
towers.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
   20 | }
      | ^