# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
116540 | 2019-06-12T20:33:38 Z | Runtime_error_ | Rice Hub (IOI11_ricehub) | C++14 | 18 ms | 3328 KB |
//IOI 2011 Day1 Problem 3 rice hub //Full solution #include "ricehub.h" //for CMS //#include "grader.h" //for yandex #include <bits/stdc++.h> #define ll long long using namespace std; const ll inf=1e5+9; ll pre[inf],a[inf],N,K; bool check(ll len){ for(ll i=len;i<=N;i++){ ll r=i,l=i-len+1,mid=(l+r)/2; ll cost=(pre[r]-pre[mid]) -(a[mid]*(r-mid)); cost+=(a[mid]*(mid-l))-(pre[mid-1]-pre[l-1]); if(cost<=K) return 1; } return 0; } int besthub(int n,int m,int x[],ll k){ N=n; K=k; for(ll i=0;i<n;i++) a[i+1]=x[i]; for(ll i=1;i<=n;i++) pre[i]=pre[i-1]+a[i]; ll ans=0; ll l=1,r=n+1; while(r-l>1){ ll mid=(l+r)/2; if(check(mid)) l=mid; else r=mid; } return (int)l; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 3 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 256 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 2 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 384 KB | Output is correct |
23 | Correct | 2 ms | 384 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
11 | Correct | 8 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 384 KB | Output is correct |
16 | Correct | 2 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 3 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 640 KB | Output is correct |
23 | Correct | 3 ms | 512 KB | Output is correct |
24 | Correct | 2 ms | 384 KB | Output is correct |
25 | Correct | 2 ms | 384 KB | Output is correct |
26 | Correct | 2 ms | 384 KB | Output is correct |
27 | Correct | 2 ms | 384 KB | Output is correct |
28 | Correct | 3 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 896 KB | Output is correct |
2 | Correct | 6 ms | 880 KB | Output is correct |
3 | Correct | 17 ms | 3320 KB | Output is correct |
4 | Correct | 17 ms | 3328 KB | Output is correct |
5 | Correct | 9 ms | 1664 KB | Output is correct |
6 | Correct | 9 ms | 1664 KB | Output is correct |
7 | Correct | 15 ms | 3072 KB | Output is correct |
8 | Correct | 17 ms | 3072 KB | Output is correct |
9 | Correct | 10 ms | 1536 KB | Output is correct |
10 | Correct | 9 ms | 1664 KB | Output is correct |
11 | Correct | 18 ms | 3320 KB | Output is correct |
12 | Correct | 17 ms | 3328 KB | Output is correct |
13 | Correct | 10 ms | 1664 KB | Output is correct |
14 | Correct | 9 ms | 1664 KB | Output is correct |
15 | Correct | 13 ms | 2560 KB | Output is correct |
16 | Correct | 13 ms | 2560 KB | Output is correct |
17 | Correct | 16 ms | 3044 KB | Output is correct |
18 | Correct | 15 ms | 2944 KB | Output is correct |
19 | Correct | 17 ms | 3200 KB | Output is correct |
20 | Correct | 17 ms | 3200 KB | Output is correct |