# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
657798 | coding_snorlax | 송신탑 (IOI22_towers) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> All;
void init(int N,vector<int> H){
for(int i=0;i<N;i++){
All.push_back(H[i]);
}
}
int recrution(int L,int R,int D){
int Now_max=-2000000000,Max_place=-1;
for(int i=L;i<=R;i++){
if(All[i]>Now_max ){
Now_max=max(Now_max,All[i]);
Max_place=i;
}
}
int flag1=0,flag2=0;
for(int i=L;i<Max_place;i++){
if(All[i]+D<=Now_max){
flag1=1;
}
}
for(int i=Max_place+1;i<=R;i++){
if(All[i]+D<=Now_max){
flag2=1;
}
}
if(flag1 && flag2) return recrution(L,Max_place-1,D)+recrution(Max_place+1,R,D);
else return 1;
}
int max_towers(int L,int R,int D){
return recrution(L,R,D);
}
int main(){
vector<int> W={10,20,60,40,50,30,70};
init(7,W);
cout<<max_towers(1,5,10)<<endl;
//cout<<max_towers(0,4,6)<<endl;
//cout<<max_towers(1,2,3)<<endl;
//cout<<max_towers(0,5,7)<<endl;
//cout<<max_towers(1,6,3)<<endl;
}