제출 #263341

#제출 시각아이디문제언어결과실행 시간메모리
263341Berted쌀 창고 (IOI11_ricehub)C++14
100 / 100
22 ms2560 KiB
#include "ricehub.h"
#include <iostream>
#define ll long long

using namespace std;

ll pref[100001];

int besthub(int R, int L, int X[], ll B)
{
	int ret = 0;
	for (int i = 1; i <= R; i++) pref[i] = pref[i - 1] + X[i - 1];
	int rg = 0; ll s = 0;
	for (int lf = 1; lf <= R; lf++)
	{
		rg = max(lf, rg);
		int md = lf + rg >> 1;
		s = pref[rg] - pref[md] - (pref[md - ((lf - rg + 1) & 1)] - pref[lf - 1]);
		while (rg <= R && s <= B)
		{
			rg++; md = lf + rg >> 1;
			s = pref[rg] - pref[md] - (pref[md - ((lf - rg + 1) & 1)] - pref[lf - 1]);
		}
		ret = max(ret, rg - lf);
	}	
	return ret;
}

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

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:17:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |   int md = lf + rg >> 1;
      |            ~~~^~~~
ricehub.cpp:21:18: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   21 |    rg++; md = lf + rg >> 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...