답안 #775510

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
775510 2023-07-06T13:09:33 Z ttamx 쌀 창고 (IOI11_ricehub) C++14
100 / 100
10 ms 1492 KB
#include "ricehub.h"
#include<bits/stdc++.h>

typedef long long ll;

using namespace std;

int besthub(int R, int L, int X[], ll B){
	vector<ll> qs(R);
	for(int i=0;i<R;i++)qs[i]=X[i];
	for(int i=1;i<R;i++)qs[i]+=qs[i-1];
	auto sum=[&](int l,int r){
		if(r<l)return 0ll;
		return qs[r]-(l>0?qs[l-1]:0);
	};
	auto check=[&](int req){
		for(int l=0,r=req-1;r<R;l++,r++){
			int m=(l+r)/2;
			ll res=(1ll*X[m]*(m-l)-sum(l,m-1))+(sum(m+1,r)-1ll*X[m]*(r-m));
			if(res<=B)return true;
		}
		return false;
	};
	int l=1,r=R;
	while(l<r){
		int m=(l+r+1)/2;
		if(check(m))l=m;
		else r=m-1;
	}
	return l;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 316 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 312 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 312 KB Output is correct
26 Correct 0 ms 212 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 1 ms 316 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 3 ms 468 KB Output is correct
3 Correct 9 ms 1400 KB Output is correct
4 Correct 10 ms 1464 KB Output is correct
5 Correct 6 ms 852 KB Output is correct
6 Correct 6 ms 852 KB Output is correct
7 Correct 9 ms 1392 KB Output is correct
8 Correct 9 ms 1492 KB Output is correct
9 Correct 6 ms 852 KB Output is correct
10 Correct 5 ms 852 KB Output is correct
11 Correct 10 ms 1468 KB Output is correct
12 Correct 10 ms 1460 KB Output is correct
13 Correct 6 ms 868 KB Output is correct
14 Correct 6 ms 852 KB Output is correct
15 Correct 7 ms 1108 KB Output is correct
16 Correct 7 ms 1196 KB Output is correct
17 Correct 8 ms 1364 KB Output is correct
18 Correct 8 ms 1364 KB Output is correct
19 Correct 9 ms 1364 KB Output is correct
20 Correct 9 ms 1324 KB Output is correct