#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
using idata = vector<int>;
idata heights;
int nbTowers;
void init(int N, idata H) {
nbTowers = N;
heights = H;
}
int max_towers(int L, int R, int D) {
idata dp(nbTowers, 0);
int curr = L; bool middle = false;
int count = 1;
for (int local = L + 1; local <= R; local ++) {
if (middle) {
if (heights[curr] >= heights[local] + D) {
curr = local;
middle = false;
count ++;
}
} else {
if (heights[local] >= heights[curr] + D) {
curr = local;
middle = true;
} else if (heights[local] < heights[curr]) curr = local;
}
}
return count;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1132 ms |
996 KB |
27th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4006 ms |
1360 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2551 ms |
644 KB |
1st lines differ - on the 1st token, expected: '7197', found: '5778' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '7' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1132 ms |
996 KB |
27th lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |