제출 #55845

#제출 시각아이디문제언어결과실행 시간메모리
55845leejseo쌀 창고 (IOI11_ricehub)C++98
0 / 100
5 ms780 KiB
#include "ricehub.h"
#include <algorithm>
using namespace std;

long long S[1000001];

inline long long val(int i){
	return i<0? 0 : S[i];
}

inline long long cost(int i, int j, int X[]){
	int mid = i+j >> 1;
	long long left = val(mid) * (mid - i) - (val(mid-1) - val(i-1));
	long long right = val(j) - val(mid) - val(mid) * (j - mid);
	return left + right;
}

int besthub(int R, int L, int X[], long long B){
	S[0] = X[0];
	for (int i=1; i<R; i++) S[i] = S[i-1] + X[i];
  int ans = 0;
	int i=0, j=0;
	for(;j<R;j++){
		if (cost(i, j, X) > B){
			i++;
			continue;
		}
		ans = max(ans, j-i+1);	
	}
	return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

ricehub.cpp: In function 'long long int cost(int, int, int*)':
ricehub.cpp:12:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
  int mid = i+j >> 1;
            ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...