Submission #94777

# Submission time Handle Problem Language Result Execution time Memory
94777 2019-01-23T17:12:44 Z MvC Rice Hub (IOI11_ricehub) C++11
100 / 100
17 ms 3320 KB
#include "ricehub.h"
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,m,l,r,mid,i;
ll b,x[nmax],s[nmax];
int ok(int k,int md)
{
    for(int i=k;i<=n;i++)
    {
        ll tot=x[i-k+md]*1LL*md-(s[i-k+md]-s[i-k])+s[i]-s[i-k+md]-1LL*(k-md)*x[i-k+md];
        if(tot<=b)return 1;
    }
    return 0;
}
int besthub(int N,int m,int y[],ll B)
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	b=B;
	n=N;
	for(i=1;i<=n;i++)
	{
	    x[i]=y[i-1];
	    s[i]=s[i-1]+x[i];
	}
	l=1,r=n;
	while(l<=r)
	{
	    mid=(l+r)/2;
	    if(ok(mid,(mid/2)+1))l=mid+1;
	    else r=mid-1;
	}
	return max(l-1,1);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 504 KB Output is correct
4 Correct 2 ms 380 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 256 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 504 KB Output is correct
22 Correct 2 ms 504 KB Output is correct
23 Correct 2 ms 504 KB Output is correct
24 Correct 2 ms 504 KB Output is correct
25 Correct 2 ms 504 KB Output is correct
26 Correct 2 ms 508 KB Output is correct
27 Correct 2 ms 504 KB Output is correct
28 Correct 2 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 760 KB Output is correct
2 Correct 5 ms 888 KB Output is correct
3 Correct 15 ms 3320 KB Output is correct
4 Correct 16 ms 3320 KB Output is correct
5 Correct 8 ms 1656 KB Output is correct
6 Correct 8 ms 1656 KB Output is correct
7 Correct 13 ms 3064 KB Output is correct
8 Correct 14 ms 3064 KB Output is correct
9 Correct 8 ms 1656 KB Output is correct
10 Correct 8 ms 1644 KB Output is correct
11 Correct 16 ms 3320 KB Output is correct
12 Correct 17 ms 3320 KB Output is correct
13 Correct 9 ms 1656 KB Output is correct
14 Correct 9 ms 1656 KB Output is correct
15 Correct 13 ms 2552 KB Output is correct
16 Correct 13 ms 2552 KB Output is correct
17 Correct 15 ms 3068 KB Output is correct
18 Correct 15 ms 3008 KB Output is correct
19 Correct 16 ms 3192 KB Output is correct
20 Correct 16 ms 3172 KB Output is correct