#include "towers.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int mx=-1;
vector<int> h;
void init(int N, std::vector<int> H) {
h=H;
for(int i=1;i<N-1;i++){
if(h[i]>h[i-1] && h[i]>h[i+1]) mx=i;
}
}
int max_towers(int L, int R, int D) {
int l=L,r=R;
if(l>=mx || r<=mx) return 1;
else{
if(h[l]+D<=h[mx] && h[r]+D<=h[mx]) return 2;
else return 1;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
309 ms |
924 KB |
Output is correct |
2 |
Correct |
708 ms |
1360 KB |
Output is correct |
3 |
Correct |
494 ms |
1360 KB |
Output is correct |
4 |
Correct |
679 ms |
1420 KB |
Output is correct |
5 |
Correct |
562 ms |
1440 KB |
Output is correct |
6 |
Correct |
573 ms |
1360 KB |
Output is correct |
7 |
Correct |
755 ms |
1452 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
# |
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 |
Incorrect |
517 ms |
1448 KB |
1st lines differ - on the 1st token, expected: '11903', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
183 ms |
556 KB |
1st lines differ - on the 1st token, expected: '7197', found: '2' |
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 |
Correct |
309 ms |
924 KB |
Output is correct |
2 |
Correct |
708 ms |
1360 KB |
Output is correct |
3 |
Correct |
494 ms |
1360 KB |
Output is correct |
4 |
Correct |
679 ms |
1420 KB |
Output is correct |
5 |
Correct |
562 ms |
1440 KB |
Output is correct |
6 |
Correct |
573 ms |
1360 KB |
Output is correct |
7 |
Correct |
755 ms |
1452 KB |
Output is correct |
8 |
Correct |
1 ms |
208 KB |
Output is correct |
9 |
Correct |
1 ms |
208 KB |
Output is correct |
10 |
Correct |
1 ms |
208 KB |
Output is correct |
11 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
12 |
Halted |
0 ms |
0 KB |
- |