제출 #71490

#제출 시각아이디문제언어결과실행 시간메모리
71490RezwanArefin01쌀 창고 (IOI11_ricehub)C++17
100 / 100
25 ms16132 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii; 

const int N = 1e5 + 10;

ll y[N]; 
int besthub(int n, int L, int x[], ll B) {
	y[0] = x[0]; 
	for(int i = 1; i < n; i++) {
		y[i] = y[i - 1] + x[i]; 
	}
	auto cost = [&x](int l, int r) {
		int m = l + r >> 1; 
		ll a = (ll) x[m] * (m - l + 1); 
		a -= y[m]; 
		if(l) a += y[l - 1]; 

		ll b = y[r] - y[m] - (r - m) * 1ll * x[m]; 
		return a + b; 
	};
	int l = 0, r = 0;
	int ans = 0; 
	while(l < n) {
		while(r < n && cost(l, r) <= B) r++; 
		ans = max(ans, r - l);
		l++;
	} return ans; 
}

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

ricehub.cpp: In lambda function:
ricehub.cpp:16:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 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...