# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1056712 |
2024-08-13T10:42:24 Z |
ttamx |
Rice Hub (IOI11_ricehub) |
C++17 |
|
10 ms |
3676 KB |
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N=1e5+5;
const ll INF=1e18;
int n;
ll b;
ll a[N],qs[N];
bool check(int s){
ll res=INF;
for(int l=1,r=s;r<=n;l++,r++){
int m=(l+r)/2;
ll val=a[m]*(m-l)-(qs[m-1]-qs[l-1])+(qs[r]-qs[m])-a[m]*(r-m);
res=min(res,val);
}
return res<=b;
}
int besthub(int _n, int L, int _a[], long long _b){
n=_n,b=_b;
for(int i=1;i<=n;i++){
a[i]=_a[i-1];
}
for(int i=1;i<=n;i++){
qs[i]=qs[i-1]+a[i];
}
int l=1,r=n;
while(l<r){
int m=(l+r+1)/2;
if(check(m)){
l=m;
}else{
r=m-1;
}
}
return l;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
0 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2396 KB |
Output is correct |
21 |
Correct |
0 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
0 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
1 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
1 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
0 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
0 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2460 KB |
Output is correct |
25 |
Correct |
1 ms |
2392 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2652 KB |
Output is correct |
2 |
Correct |
2 ms |
2396 KB |
Output is correct |
3 |
Correct |
7 ms |
2496 KB |
Output is correct |
4 |
Correct |
8 ms |
3676 KB |
Output is correct |
5 |
Correct |
7 ms |
3012 KB |
Output is correct |
6 |
Correct |
5 ms |
2908 KB |
Output is correct |
7 |
Correct |
6 ms |
3248 KB |
Output is correct |
8 |
Correct |
8 ms |
3420 KB |
Output is correct |
9 |
Correct |
7 ms |
2908 KB |
Output is correct |
10 |
Correct |
5 ms |
2908 KB |
Output is correct |
11 |
Correct |
7 ms |
3676 KB |
Output is correct |
12 |
Correct |
10 ms |
3676 KB |
Output is correct |
13 |
Correct |
5 ms |
2908 KB |
Output is correct |
14 |
Correct |
5 ms |
2908 KB |
Output is correct |
15 |
Correct |
10 ms |
3240 KB |
Output is correct |
16 |
Correct |
8 ms |
3240 KB |
Output is correct |
17 |
Correct |
7 ms |
3420 KB |
Output is correct |
18 |
Correct |
6 ms |
3496 KB |
Output is correct |
19 |
Correct |
7 ms |
3504 KB |
Output is correct |
20 |
Correct |
9 ms |
3500 KB |
Output is correct |