#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define pb push_back
typedef int64_t lld;
typedef pair<int, int> pii;
vector<lld> v;
int besthub(int R, int L, int X[], long long B) {
int l = 0, r = R+1;
v.pb(0);
for(int i = 0; i < R; i++)v.pb(X[i]+v.back());
while(r-l > 1){
int d = (l+r)/2; bool fl = false;
for(int i = 0; i+d-1 < R; i++){
int med = X[i+d/2];
lld dist = (v[i+d]-v[i+d/2])-(lld)med*(d-(d/2)) + (lld)med*(d/2)-(v[i+d/2]-v[i]);
//cout << i << " " << i+d-1 << " " << dist << endl;
if(dist <= B)fl = true;
}
if(fl)l = d;
else r = d;
}
return l;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
256 KB |
Output is correct |
5 |
Correct |
1 ms |
256 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
0 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
256 KB |
Output is correct |
12 |
Correct |
0 ms |
256 KB |
Output is correct |
13 |
Correct |
0 ms |
256 KB |
Output is correct |
14 |
Correct |
0 ms |
256 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
256 KB |
Output is correct |
17 |
Correct |
0 ms |
384 KB |
Output is correct |
18 |
Correct |
0 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
0 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
0 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
1 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
384 KB |
Output is correct |
18 |
Correct |
1 ms |
384 KB |
Output is correct |
19 |
Correct |
1 ms |
288 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
512 KB |
Output is correct |
22 |
Correct |
1 ms |
416 KB |
Output is correct |
23 |
Correct |
1 ms |
512 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
1 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
896 KB |
Output is correct |
2 |
Correct |
4 ms |
896 KB |
Output is correct |
3 |
Correct |
19 ms |
2928 KB |
Output is correct |
4 |
Correct |
20 ms |
2936 KB |
Output is correct |
5 |
Correct |
10 ms |
1532 KB |
Output is correct |
6 |
Correct |
10 ms |
1532 KB |
Output is correct |
7 |
Correct |
17 ms |
2680 KB |
Output is correct |
8 |
Correct |
25 ms |
2680 KB |
Output is correct |
9 |
Correct |
10 ms |
1404 KB |
Output is correct |
10 |
Correct |
9 ms |
1404 KB |
Output is correct |
11 |
Correct |
21 ms |
2936 KB |
Output is correct |
12 |
Correct |
22 ms |
2928 KB |
Output is correct |
13 |
Correct |
10 ms |
1532 KB |
Output is correct |
14 |
Correct |
10 ms |
1532 KB |
Output is correct |
15 |
Correct |
16 ms |
2552 KB |
Output is correct |
16 |
Correct |
16 ms |
2552 KB |
Output is correct |
17 |
Correct |
19 ms |
2808 KB |
Output is correct |
18 |
Correct |
18 ms |
2808 KB |
Output is correct |
19 |
Correct |
20 ms |
2800 KB |
Output is correct |
20 |
Correct |
28 ms |
2808 KB |
Output is correct |