#include "towers.h"
#include <bits/stdc++.h>
#define fs first
#define sc second
#define p_q priority_queue
using namespace std;
vector<int> v;
int mx;
int n;
void init(int N, vector<int> h) {
v=h;
n=N;
mx=0;
for(int i=1;i<n;i++){
if(v[i]>v[mx]){
mx=i;
}
}
}
int max_towers(int L, int R, int d) {
if(L>=mx || R<=mx){
return 0;
}
int u=0;
if(mx!=0){
int l=0,r=mx-1;
while(r>l){
int m=(l+r+1)/2;
if(v[m]+d>v[mx]){
r=m-1;
}
else{
l=m;
}
}
u+=max(0,l-L+1);
}
if(mx+1!=n){
int l=mx+1,r=n-1;
while(r>l){
int m=(l+r)/2;
if(v[m]+d>v[mx]){
l=m+1;
}
else{
r=m;
}
}
u+=max(0,R-l+1);
}
return u;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
286 ms |
932 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: '45' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '45' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
413 ms |
1324 KB |
1st lines differ - on the 1st token, expected: '11903', found: '35959' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
183 ms |
564 KB |
1st lines differ - on the 1st token, expected: '7197', found: '23808' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
1st lines differ - on the 1st token, expected: '13', found: '45' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
286 ms |
932 KB |
1st lines differ - on the 1st token, expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |