#include "towers.h"
#include<bits/stdc++.h>
int vis[5000]={0};
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 max_towers(int L,int R,int D){
for(int i=L;i<=R;i++){
vis[i]=0;
}
int Max_place=-1;
int Answer=1;
int flag=1;
for(int Case=L;Case<=R;Case++){
int start=0;
int Now_max=-2000000000;
if(!flag) break;
for(int i=L;i<=R;i++){
if(All[i]>Now_max && !vis[i]){
Now_max=max(Now_max,All[i]);
Max_place=i;
}
}
vis[Max_place]=1;
int check=1;
int have_1=0;
for(int i=L;i<=R;i++){
if(vis[i]==1 && have_1) check=0;
else if(vis[i]==1 && !have_1) have_1=1;
else have_1=0;
}
//cout<<check<<endl;
if(check){
int local_Max=-2000000000;
int Block=-2000000000;
for(int i=L;i<=R;i++){
if(vis[i]){
if(local_Max+D>max(Block,Now_max) && start){
flag=0;
break;
}
Block=Now_max;
local_Max=-2000000000;
start=0;
}
else{
local_Max=max(local_Max,All[i]);
start=1;
}
}
if(local_Max+D>max(Block,Now_max) || !start){
flag=0;
break;
}
}
else{
flag=0;
}
if(flag) Answer++;
}
return Answer;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
1680 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
15 ms |
2220 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1188 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
9 ms |
1680 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |