답안 #49777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
49777 2018-06-03T02:13:03 Z 노영훈(#1276, Diuven) 쌀 창고 (IOI11_ricehub) C++11
100 / 100
33 ms 2172 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 488 KB Output is correct
3 Correct 2 ms 508 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 548 KB Output is correct
2 Correct 2 ms 548 KB Output is correct
3 Correct 2 ms 548 KB Output is correct
4 Correct 3 ms 548 KB Output is correct
5 Correct 2 ms 548 KB Output is correct
6 Correct 2 ms 548 KB Output is correct
7 Correct 3 ms 548 KB Output is correct
8 Correct 2 ms 548 KB Output is correct
9 Correct 2 ms 548 KB Output is correct
10 Correct 2 ms 620 KB Output is correct
11 Correct 2 ms 620 KB Output is correct
12 Correct 3 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 2 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 2 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 2 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 2 ms 724 KB Output is correct
22 Correct 3 ms 724 KB Output is correct
23 Correct 2 ms 724 KB Output is correct
24 Correct 3 ms 724 KB Output is correct
25 Correct 3 ms 724 KB Output is correct
26 Correct 2 ms 724 KB Output is correct
27 Correct 3 ms 724 KB Output is correct
28 Correct 2 ms 724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 2 ms 724 KB Output is correct
3 Correct 2 ms 724 KB Output is correct
4 Correct 2 ms 724 KB Output is correct
5 Correct 2 ms 724 KB Output is correct
6 Correct 2 ms 724 KB Output is correct
7 Correct 3 ms 724 KB Output is correct
8 Correct 3 ms 724 KB Output is correct
9 Correct 2 ms 724 KB Output is correct
10 Correct 2 ms 724 KB Output is correct
11 Correct 2 ms 724 KB Output is correct
12 Correct 2 ms 724 KB Output is correct
13 Correct 3 ms 724 KB Output is correct
14 Correct 3 ms 724 KB Output is correct
15 Correct 3 ms 724 KB Output is correct
16 Correct 3 ms 724 KB Output is correct
17 Correct 3 ms 724 KB Output is correct
18 Correct 2 ms 724 KB Output is correct
19 Correct 3 ms 724 KB Output is correct
20 Correct 3 ms 724 KB Output is correct
21 Correct 3 ms 724 KB Output is correct
22 Correct 4 ms 740 KB Output is correct
23 Correct 3 ms 740 KB Output is correct
24 Correct 7 ms 740 KB Output is correct
25 Correct 7 ms 740 KB Output is correct
26 Correct 3 ms 740 KB Output is correct
27 Correct 2 ms 740 KB Output is correct
28 Correct 3 ms 740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 868 KB Output is correct
2 Correct 6 ms 868 KB Output is correct
3 Correct 21 ms 2156 KB Output is correct
4 Correct 20 ms 2156 KB Output is correct
5 Correct 11 ms 2156 KB Output is correct
6 Correct 10 ms 2156 KB Output is correct
7 Correct 31 ms 2156 KB Output is correct
8 Correct 33 ms 2156 KB Output is correct
9 Correct 9 ms 2156 KB Output is correct
10 Correct 11 ms 2156 KB Output is correct
11 Correct 31 ms 2156 KB Output is correct
12 Correct 23 ms 2172 KB Output is correct
13 Correct 12 ms 2172 KB Output is correct
14 Correct 14 ms 2172 KB Output is correct
15 Correct 16 ms 2172 KB Output is correct
16 Correct 17 ms 2172 KB Output is correct
17 Correct 19 ms 2172 KB Output is correct
18 Correct 20 ms 2172 KB Output is correct
19 Correct 22 ms 2172 KB Output is correct
20 Correct 21 ms 2172 KB Output is correct