#include <bits/stdc++.h>
using namespace std;
#include "towers.h"
#define pb push_back
#define ll long long
#define fi first
#define se second
int k=-1,n;
vector<int> tab;
void init(int N, std::vector<int> H) {
n=N;
for (int i = 0; i < N; ++i)
{
tab.pb(H[i]);
}
for (int i = 0; i < N-1; ++i)
{
if(tab[i]>tab[i+1]){
k=i;
break;
}
}
}
int max_towers(int L, int R, int D){
if(L>=k||R<=k) return 1;
int l=L-1;
int r=k;
while(r-l>1){
int mid=(r+l)/2;
if(tab[mid]>tab[k]-D) r=mid;
else l=mid;
}
int a=l;
l=k;
r=R+1;
while(r-l>1){
int mid=(r+l)/2;
if(tab[mid]>tab[k]-D) l=mid;
else r=mid;
}
if(a==L-1||r==R+1) return 1;
int ans=max(1,min(2,a-L+1+R-r+1));
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
289 ms |
1236 KB |
Output is correct |
2 |
Correct |
586 ms |
1744 KB |
Output is correct |
3 |
Correct |
595 ms |
1748 KB |
Output is correct |
4 |
Correct |
673 ms |
1748 KB |
Output is correct |
5 |
Correct |
571 ms |
1748 KB |
Output is correct |
6 |
Correct |
606 ms |
1748 KB |
Output is correct |
7 |
Correct |
595 ms |
1748 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
449 ms |
1720 KB |
1st lines differ - on the 1st token, expected: '11903', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
166 ms |
856 KB |
1st lines differ - on the 1st token, expected: '7197', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
289 ms |
1236 KB |
Output is correct |
2 |
Correct |
586 ms |
1744 KB |
Output is correct |
3 |
Correct |
595 ms |
1748 KB |
Output is correct |
4 |
Correct |
673 ms |
1748 KB |
Output is correct |
5 |
Correct |
571 ms |
1748 KB |
Output is correct |
6 |
Correct |
606 ms |
1748 KB |
Output is correct |
7 |
Correct |
595 ms |
1748 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
0 ms |
344 KB |
Output is correct |
11 |
Incorrect |
1 ms |
596 KB |
1st lines differ - on the 1st token, expected: '13', found: '1' |
12 |
Halted |
0 ms |
0 KB |
- |