#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