Submission #228484

# Submission time Handle Problem Language Result Execution time Memory
228484 2020-05-01T07:41:05 Z bharat2002 Rice Hub (IOI11_ricehub) C++14
0 / 100
8 ms 768 KB
/*input

*/
#include<bits/stdc++.h>
#include "ricehub.h"
using namespace std;
const int N=1e5+100;
const int mod=1e9 + 7;
#define pii pair<int, int>
#define f first
#define s second 
#define mp make_pair
#define FOR(i, n) for(int i=1;i<=n;i++)
#define TRACE(x) cerr << #x << " = " << x << endl 
//Trace prints the name of the variable and the value.
int besthub(int n, int L, int arr[], long long tot)
{
	int l=1, r=1;
	vector<pii> vals;long long rem=tot;int ans=1;
	for(int i=1;i<=n;i++)
	{
		while(l<i&&r<n&&arr[i]-arr[l]>arr[r+1]-arr[i])
		{
			rem+=arr[i]-arr[l];rem-=arr[r+1]-arr[i];r++;l++;
		}
		while(l>1&&r<n)
		{
			int cost=min(arr[i]-arr[l-1], arr[r+1]-arr[i]);
			if(cost>rem) break;
			if(arr[i]-arr[l-1]< arr[r+1]-arr[i])
			{
				l--;
			}
			else r++;
			rem-=cost;
		}
		while(r<n)
		{
			int cost= arr[r+1]-arr[i];
			if(cost>rem) break;r++;
			rem-=cost;	
		}
		while(l>1)
		{
			int cost= arr[i]-arr[l-1];
			if(cost>rem) break;l--;
			rem-=cost;	
		}
		vals.push_back(mp(l, r));ans=max(ans, r-l+1);
	}
	if(vals.size()>1)
	{	for(int i=1;i<(int)vals.size();i++)
		{
			if(vals[i].s==n) break;
			assert(vals[i].f>=vals[i-1].f);
		}
	}
	return ans;
}
/*signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n, b;cin>>n>>b;int arr[N];
	for(int i=1;i<=n;i++)
	{
		cin>>arr[i];
	}	
	cout<<besthub(n, 0, arr, b);
}*/

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:40:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(cost>rem) break;r++;
    ^~
ricehub.cpp:40:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if(cost>rem) break;r++;
                       ^
ricehub.cpp:46:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if(cost>rem) break;l--;
    ^~
ricehub.cpp:46:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if(cost>rem) break;l--;
                       ^
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 768 KB Output isn't correct
2 Halted 0 ms 0 KB -