#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> he;
int k=0;
void init (int n,vector<int> h)
{
he.resize(n);
for(int x=0;x<n;x++)
{
he[x]=h[x];
if(h[x]>h[x+1] && x!=n)
k=x;
}
if(h[n-1]>h[n-2])
k=n-1;
}
int max_towers(int l, int r, int d)
{
if(k>=r || k<=l)
return 0;
int ml=k,mr=r;
while(ml!=mr)
{
int mid=(ml+mr)/2;
if(he[mid]>he[k]-d)
ml=mid+1;
else
mr=mid;
}
int a1=mr,a2=0;
ml=l,mr=k;
while(ml!=mr)
{
int mid=(ml+mr)/2;
if(he[mid]<he[k]-d)
ml=mid+1;
else
mr=mid;
}
a2=mr;
return ((r-a2+1)*(a1-l+1));
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
389 ms |
928 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
624 ms |
1456 KB |
1st lines differ - on the 1st token, expected: '11903', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
159 ms |
556 KB |
1st lines differ - on the 1st token, expected: '7197', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
389 ms |
928 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |