# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
824230 | Liudas | Radio Towers (IOI22_towers) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}