Submission #20803

# Submission time Handle Problem Language Result Execution time Memory
20803 2017-02-16T08:13:23 Z jjwdi0 Rice Hub (IOI11_ricehub) C++11
Compilation error
0 ms 0 KB
#include "ricehub.h"
#define MAX_N 100005
typedef long long ll;

int max(int X, int Y){return X>Y?X:Y;}
int besthub(int R, ll L, ll B, ll X[]) {
	int ans = 0;
	int i = 1, j = 1;
	ll cnt = 0LL, A[MAX_N];
	for(int i=R-1; i>=0; i--) X[i+1] = X[i];
	A[0] = 0LL;
	for(int i=1; i<=R; i++) A[i] = A[i-1] + X[i];
	while(i <= R && j <= R) {
		int mid = i + j >> 1;
		while(X[(i+j)/2] * (ll)((i+j)/2 - i + 1) - (A[(i+j)/2] - A[i-1]) + A[j] - X[(i+j)/2] * (ll)(j - (i+j)/2 + 1) - A[(i+j)/2 - 1] > B && i < j) i++;
		ans = max(ans, j - i + 1);
		j++;
	}
	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, ll, ll, ll*)':
ricehub.cpp:14:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = i + j >> 1;
               ^
ricehub.cpp:14:7: warning: unused variable 'mid' [-Wunused-variable]
   int mid = i + j >> 1;
       ^
ricehub.cpp:9:5: warning: unused variable 'cnt' [-Wunused-variable]
  ll cnt = 0LL, A[MAX_N];
     ^
/tmp/ccbOF1bs.o: In function `main':
grader.cpp:(.text.startup+0x92): undefined reference to `besthub(int, int, int*, long long)'
collect2: error: ld returned 1 exit status