| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332507 | opeleklanos | 송신탑 (IOI22_towers) | C++20 | 0 ms | 0 KiB |
#include <iostream>
#include <vector>
using namespace std;
int k = 0;
vector<int> h;
int n;
void init (int n1, vector<int> h1){
n = n1;
h = h1;
for(int i = 1; i<n; i++){
if(h[i] > h[i-1]) k = i;
}
}
int max_towers(int l, int r, int d){
if(l+1 == r || k<=l || k>=r) return 1;
if(h[l] + d <= h[k] && h[r]+d<=h[k]) return 2;
return 1;
}
int main(void){
freopen("input.txt", "r", stdin);
int n1; cin>>n1;
vector<int> h1(n1, 0);
for(int i = 0; i<n1; i++) cin>>h1[i];
init(n1, h1);
int q1; cin>>q1;
for(int i = 0; i<q1; i++){
int a, b, d;
cin>>a>>b>>d;
cout<<max_towers(a, b, d);
}
}