Submission #285030

# Submission time Handle Problem Language Result Execution time Memory
285030 2020-08-28T09:11:59 Z Bill_00 Rice Hub (IOI11_ricehub) C++14
0 / 100
4 ms 512 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define MAX_R  1000000

int besthub(int R, int L, int a[], long long B)
{
	int dp[100001];
	dp[0]=0;
	for(int i=1;i<R;i++){
		dp[i]=dp[i-1]+a[i]-a[0];
	}
	int l=1,r=R;
	while(l!=r){
		int mid=l+r>>1,flag=0;
		for(int i=mid-1;i<R;i++){
			int MID=i+i+1-mid>>1;
			int left=i+1-mid;
			int cost=dp[i]-dp[MID]-((i-MID)*(a[MID]-a[0]))+((a[MID]-a[left])*(MID-left+1)-(dp[MID]-dp[left]-(MID-left)*(a[left]-a[0])));
			if(cost<=B){
				flag++;
				break;
			}
		}
		if(flag==0) r=mid;
		else l=mid+1;
	}
	return l;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:15:12: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   15 |   int mid=l+r>>1,flag=0;
      |           ~^~
ricehub.cpp:17:17: warning: suggest parentheses around '-' inside '>>' [-Wparentheses]
   17 |    int MID=i+i+1-mid>>1;
      |            ~~~~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 512 KB Output isn't correct
2 Halted 0 ms 0 KB -