#include <bits/stdc++.h>
#include "towers.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
vi v;
int n;
void init(int N, vi h) {
v=h;
n=N;
}
int max_towers(int l, int r, int d) {
int ans=0;
int v1=-1;
int p1=-1;
bool ban=false;
for(int i=1; i<n; i++){
if(v[i]<v[i-1]){
if(p1!=-1){
if(p1-v1>d){
p1=v1=-1;
}else{
ban=true;
}
}
}
if(v[i]>v[i-1]){
if(ban==true){
ans++;
ban=false;
}
if(v1==-1){
v1=v[i-1];
}
p1=v[i];
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2423 ms |
1112 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4059 ms |
1368 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2024 ms |
688 KB |
1st lines differ - on the 1st token, expected: '7197', found: '7264' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
1st lines differ - on the 1st token, expected: '13', found: '6' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2423 ms |
1112 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |