Submission #170424

# Submission time Handle Problem Language Result Execution time Memory
170424 2019-12-25T08:23:54 Z nafis_shifat Rice Hub (IOI11_ricehub) C++14
0 / 100
8 ms 888 KB
#include "ricehub.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mxn=1e5+5;
const ll inf=2e15+5;

ll ar[mxn];
int besthub(int R, int L, int X[], long long B)
{
	ll tot[mxn];
	tot[0]=0;
	for(int i=1;i<=R;i++)
	{
		ar[i]=X[i-1];
		tot[i]=tot[i-1]+ar[i];
	}

	int ans=0;

	for(int i=1;i<=R;i++)
	{


		int lo=i;
		int hi=R;


		while(lo<=hi)
		{
			int mid=lo+hi>>1;

			int k=mid-i;

			ll ts=(tot[mid]-tot[i])-(ar[i]*k);
			ll t2=inf;
			int ind=max(1,i-k-1);


			int r=0;
			for(int j=0;j<3 && ind+j<i;j++)
			{
				ll tmp=ar[i]*(i-ind-j)-tot[i-1]-tot[ind+j-1];

				if(tmp+ts<=B)
				{
					r=i-ind-j;
					t2=tmp;
					break;
				}				
			}



			if(ts+t2<=B)
			{
				ans=max(ans,k+r+1);
				lo=mid+1;
			}
			else
			{
				hi=mid-1;
			}

		}

	}


	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid=lo+hi>>1;
            ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 888 KB Output isn't correct
2 Halted 0 ms 0 KB -