#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);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2101 ms |
1104 KB |
Output is correct |
2 |
Execution timed out |
4054 ms |
1684 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4050 ms |
1692 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4093 ms |
592 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2101 ms |
1104 KB |
Output is correct |
2 |
Execution timed out |
4054 ms |
1684 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |