Submission #211554

# Submission time Handle Problem Language Result Execution time Memory
211554 2020-03-20T17:13:22 Z bigg Rice Hub (IOI11_ricehub) C++14
0 / 100
8 ms 896 KB
#include "ricehub.h"
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 112345;

long long int ar[MAXN];
long long sumr[MAXN];
int besthub(int R, int L, int X[], long long B)
{	
	//sumr[0] = X[0]
	for(int i = 1; i <= R; i++){
		ar[i] = X[i - 1];
		sumr[i] = sumr[i - 1] + ar[i];

	}
	long long int ans = 0;
	for(int i = 1; i <= R; i++){
		long long int l = i, r = R, j; 
		while(r - l >= 0){
			long long int mid = (l + r)/2;
			long long int mid2 = mid/2;
			long long cost = ar[mid2] * (mid2 - i + 1) - (sumr[mid2] - sumr[i - 1])
				+ (sumr[mid] - sumr[mid2]) -  ar[mid2] * (mid - mid2);
			if(cost <= B){
				j = mid; l = mid + 1;
			}else
				r = mid - 1;

		}
		ans = max(ans, j - i + 1);
	}
	return (int) ++ans;

}
 

// int r, l, x[MAXN];
// long long b;

//  int main(){
//  	scanf("%d %d %lld", &r, &l, &b);
//  	for(int i = 0; i < r; i++){
//  		scanf("%d", &x[i] );
//  	}
//  	printf("%d\n", besthub(r, l, x, b));


//  }

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:30:20: warning: 'j' may be used uninitialized in this function [-Wmaybe-uninitialized]
   ans = max(ans, j - i + 1);
                  ~~^~~
# 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 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 896 KB Output isn't correct
2 Halted 0 ms 0 KB -