답안 #49996

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49996 2018-06-06T04:40:19 Z Diuven 쌀 창고 (IOI11_ricehub) C++11
100 / 100
27 ms 2284 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const int MX=100010;

int X[MX], n, xmx;
ll S[MX];

ll _max(ll a, ll b){
	return a>b ? a : b;
}

ll cost(int l, int r){
	int mid=(l+r)/2;
	ll leftsum = 1LL*X[mid]*(mid-l+1) - (S[mid]-S[l-1]);
	ll rigtsum = (S[r]-S[mid]) - 1LL*X[mid]*(r-mid);
	return leftsum+rigtsum;
}

ll solve(ll maxCost){
	ll ans=0;
	for(int l=1, r=1; l<=n; l++){
		r=max(r,l);
		while(r<n && cost(l,r+1)<=maxCost) r++;
		if(cost(l,r)>maxCost) continue;
		ans=_max(ans, 0LL+r-l+1);
	}
	return ans;
}

int besthub(int R, int L, int XX[], ll B) {
	n=R, xmx=L;
	for(int i=1; i<=n; i++){
		X[i]=XX[i-1];
		S[i]=S[i-1]+X[i];
	}
	return solve(B);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 428 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 616 KB Output is correct
2 Correct 2 ms 616 KB Output is correct
3 Correct 2 ms 616 KB Output is correct
4 Correct 2 ms 616 KB Output is correct
5 Correct 2 ms 616 KB Output is correct
6 Correct 2 ms 740 KB Output is correct
7 Correct 2 ms 740 KB Output is correct
8 Correct 2 ms 740 KB Output is correct
9 Correct 2 ms 740 KB Output is correct
10 Correct 3 ms 740 KB Output is correct
11 Correct 2 ms 740 KB Output is correct
12 Correct 2 ms 740 KB Output is correct
13 Correct 2 ms 740 KB Output is correct
14 Correct 2 ms 740 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 3 ms 760 KB Output is correct
18 Correct 2 ms 760 KB Output is correct
19 Correct 3 ms 760 KB Output is correct
20 Correct 2 ms 760 KB Output is correct
21 Correct 2 ms 760 KB Output is correct
22 Correct 2 ms 760 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
24 Correct 3 ms 760 KB Output is correct
25 Correct 2 ms 760 KB Output is correct
26 Correct 2 ms 760 KB Output is correct
27 Correct 2 ms 760 KB Output is correct
28 Correct 2 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 3 ms 760 KB Output is correct
5 Correct 3 ms 760 KB Output is correct
6 Correct 3 ms 760 KB Output is correct
7 Correct 3 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 3 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 760 KB Output is correct
12 Correct 3 ms 760 KB Output is correct
13 Correct 2 ms 760 KB Output is correct
14 Correct 2 ms 760 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 760 KB Output is correct
18 Correct 2 ms 760 KB Output is correct
19 Correct 3 ms 760 KB Output is correct
20 Correct 3 ms 760 KB Output is correct
21 Correct 3 ms 760 KB Output is correct
22 Correct 3 ms 760 KB Output is correct
23 Correct 3 ms 760 KB Output is correct
24 Correct 3 ms 760 KB Output is correct
25 Correct 3 ms 760 KB Output is correct
26 Correct 3 ms 760 KB Output is correct
27 Correct 3 ms 760 KB Output is correct
28 Correct 3 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 892 KB Output is correct
2 Correct 4 ms 892 KB Output is correct
3 Correct 22 ms 2172 KB Output is correct
4 Correct 22 ms 2172 KB Output is correct
5 Correct 10 ms 2172 KB Output is correct
6 Correct 10 ms 2172 KB Output is correct
7 Correct 17 ms 2284 KB Output is correct
8 Correct 16 ms 2284 KB Output is correct
9 Correct 9 ms 2284 KB Output is correct
10 Correct 10 ms 2284 KB Output is correct
11 Correct 22 ms 2284 KB Output is correct
12 Correct 20 ms 2284 KB Output is correct
13 Correct 10 ms 2284 KB Output is correct
14 Correct 12 ms 2284 KB Output is correct
15 Correct 21 ms 2284 KB Output is correct
16 Correct 15 ms 2284 KB Output is correct
17 Correct 18 ms 2284 KB Output is correct
18 Correct 18 ms 2284 KB Output is correct
19 Correct 27 ms 2284 KB Output is correct
20 Correct 19 ms 2284 KB Output is correct