# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
222598 |
2020-04-13T11:41:13 Z |
MODDI |
Rice Hub (IOI11_ricehub) |
C++14 |
|
30 ms |
2560 KB |
#include <bits/stdc++.h>
using namespace std;
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0);
#define forinc(a,b,c) for(int a=b,_c=c;a<=_c;++a)
#define fordec(a,b,c) for(int a=b,_c=c;a>=_c;--a)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define on(x,i) (x|(1ll<<(i-1)))
#define off(x,i) (x&~(1<<(i-1)))
#define gg exit(0);
//#define unx 1
#ifndef unx
#include "ricehub.h"
#endif // unx
//long long s[100010];
int besthub(int r,int l,int x[],long long b){
int best=0;
vector<long long> s(r+1);
forinc(i,1,r) s[i]=s[i-1]+x[i-1];
int le,mi,ri,ret;
forinc(i,1,r){
le=0,ri=min(i-1,r-i),ret=-1;
while(le<=ri){
mi=(le+ri)/2;
if(s[i+mi]-s[i]-s[i-1]+s[i-mi-1]<=b) ret=mi,le=mi+1;
else ri=mi-1;
}
best=max(best,ret+ret+1);
le=0,ri=min(i-1,r-i-1),ret=-1;
while(le<=ri){
mi=(le+ri)/2;
if(s[i+mi+1]-s[i]-s[i-1]+s[i-mi-1]-x[i-1]<=b) ret=mi,le=mi+1;
else ri=mi-1;
}
best=max(best,ret+ret+2);
}
return best;
}
#ifdef unx
int a[100010];
main(){
#define task "rice"
//freopen(task".inp","r",stdin);
//freopen(task".out","w",stdout);
int r,l; long long b;
cin>>r>>l>>b;
forinc(i,1,r) cin>>a[i-1];
cout<<besthub(r,l,a,b);
cerr<<besthub(r,l,a,b);
}
#endif // unx
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
4 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
256 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
4 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
4 ms |
384 KB |
Output is correct |
21 |
Correct |
5 ms |
384 KB |
Output is correct |
22 |
Correct |
5 ms |
384 KB |
Output is correct |
23 |
Correct |
5 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
5 ms |
256 KB |
Output is correct |
26 |
Correct |
5 ms |
384 KB |
Output is correct |
27 |
Correct |
5 ms |
384 KB |
Output is correct |
28 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
5 ms |
384 KB |
Output is correct |
13 |
Correct |
5 ms |
384 KB |
Output is correct |
14 |
Correct |
5 ms |
384 KB |
Output is correct |
15 |
Correct |
5 ms |
384 KB |
Output is correct |
16 |
Correct |
5 ms |
384 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
5 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
21 |
Correct |
6 ms |
384 KB |
Output is correct |
22 |
Correct |
6 ms |
384 KB |
Output is correct |
23 |
Correct |
6 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
6 ms |
384 KB |
Output is correct |
26 |
Correct |
6 ms |
384 KB |
Output is correct |
27 |
Correct |
6 ms |
384 KB |
Output is correct |
28 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
640 KB |
Output is correct |
2 |
Correct |
8 ms |
640 KB |
Output is correct |
3 |
Correct |
28 ms |
2552 KB |
Output is correct |
4 |
Correct |
28 ms |
2560 KB |
Output is correct |
5 |
Correct |
15 ms |
1280 KB |
Output is correct |
6 |
Correct |
14 ms |
1280 KB |
Output is correct |
7 |
Correct |
25 ms |
2304 KB |
Output is correct |
8 |
Correct |
25 ms |
2304 KB |
Output is correct |
9 |
Correct |
16 ms |
1152 KB |
Output is correct |
10 |
Correct |
16 ms |
1152 KB |
Output is correct |
11 |
Correct |
29 ms |
2560 KB |
Output is correct |
12 |
Correct |
30 ms |
2560 KB |
Output is correct |
13 |
Correct |
15 ms |
1280 KB |
Output is correct |
14 |
Correct |
16 ms |
1280 KB |
Output is correct |
15 |
Correct |
23 ms |
2048 KB |
Output is correct |
16 |
Correct |
23 ms |
2048 KB |
Output is correct |
17 |
Correct |
27 ms |
2304 KB |
Output is correct |
18 |
Correct |
26 ms |
2304 KB |
Output is correct |
19 |
Correct |
28 ms |
2432 KB |
Output is correct |
20 |
Correct |
28 ms |
2432 KB |
Output is correct |