# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
708897 | 2023-03-12T15:29:56 Z | sofija6 | Rice Hub (IOI11_ricehub) | C++14 | 23 ms | 3276 KB |
#include <bits/stdc++.h> #define ll long long #define MAXR 100010 using namespace std; ll pref[MAXR],a[MAXR]; ll Calc(ll L,ll R,ll pos) { ll l=L,r=R,mid,p; while (l<=r) { mid=(l+r)/2; if (a[mid]<=pos) { p=mid; l=mid+1; } else r=mid-1; } return pos*(p-L+1)-(pref[p]-pref[L-1])+pref[R]-pref[p]-pos*(R-p); } ll Check(ll x,ll n) { ll ans=LLONG_MAX; for (ll i=1;i<=n-x+1;i++) ans=min(ans,Calc(i,i+x-1,a[(2*i+x)/2])); return ans; } int besthub(int R,int L,int X[],ll B) { for (ll i=0;i<R;i++) { pref[i+1]=pref[i]+X[i]; a[i+1]=X[i]; } int l=1,r=R,mid,ans; while (l<=r) { mid=(l+r)/2; if (Check(mid,R)<=B) { ans=mid; l=mid+1; } else r=mid-1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 304 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 300 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 312 KB | Output is correct |
14 | Correct | 1 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 212 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 1 ms | 212 KB | Output is correct |
20 | Correct | 1 ms | 212 KB | Output is correct |
21 | Correct | 1 ms | 212 KB | Output is correct |
22 | Correct | 1 ms | 312 KB | Output is correct |
23 | Correct | 1 ms | 212 KB | Output is correct |
24 | Correct | 1 ms | 212 KB | Output is correct |
25 | Correct | 1 ms | 308 KB | Output is correct |
26 | Correct | 1 ms | 212 KB | Output is correct |
27 | Correct | 1 ms | 212 KB | Output is correct |
28 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 300 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 312 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 304 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 1 ms | 212 KB | Output is correct |
17 | Correct | 1 ms | 316 KB | Output is correct |
18 | Correct | 1 ms | 312 KB | Output is correct |
19 | Correct | 1 ms | 340 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 2 ms | 340 KB | Output is correct |
22 | Correct | 2 ms | 348 KB | Output is correct |
23 | Correct | 1 ms | 340 KB | Output is correct |
24 | Correct | 1 ms | 340 KB | Output is correct |
25 | Correct | 1 ms | 340 KB | Output is correct |
26 | Correct | 1 ms | 340 KB | Output is correct |
27 | Correct | 2 ms | 340 KB | Output is correct |
28 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 832 KB | Output is correct |
2 | Correct | 6 ms | 724 KB | Output is correct |
3 | Correct | 15 ms | 3240 KB | Output is correct |
4 | Correct | 16 ms | 3276 KB | Output is correct |
5 | Correct | 16 ms | 1600 KB | Output is correct |
6 | Correct | 15 ms | 1620 KB | Output is correct |
7 | Correct | 13 ms | 2984 KB | Output is correct |
8 | Correct | 15 ms | 2912 KB | Output is correct |
9 | Correct | 22 ms | 1492 KB | Output is correct |
10 | Correct | 23 ms | 1492 KB | Output is correct |
11 | Correct | 19 ms | 3260 KB | Output is correct |
12 | Correct | 15 ms | 3208 KB | Output is correct |
13 | Correct | 15 ms | 1580 KB | Output is correct |
14 | Correct | 15 ms | 1628 KB | Output is correct |
15 | Correct | 11 ms | 2516 KB | Output is correct |
16 | Correct | 16 ms | 2456 KB | Output is correct |
17 | Correct | 13 ms | 2940 KB | Output is correct |
18 | Correct | 20 ms | 2980 KB | Output is correct |
19 | Correct | 13 ms | 3156 KB | Output is correct |
20 | Correct | 15 ms | 3080 KB | Output is correct |