답안 #259504

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259504 2020-08-07T23:41:41 Z amiratou 쌀 창고 (IOI11_ricehub) C++14
100 / 100
27 ms 1536 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll cum[100000];
ll sum(int a,int b){
	if(a>b)return 0;
	return cum[b]-(a?cum[a-1]:0);
}
 
int besthub(int R, int L, int X[], long long B)
{
	for (int i = 0; i < R; ++i)
	{
		cum[i]=X[i];
		if(i)cum[i]+=cum[i-1];
	}
	int ans=1;
	for (int i = 0; i < R; ++i)
		for (int j = i+ans; j < R; ++j)
		{
			int idx=i+(j-i)/2;
			int nb_a=idx-i,nb_b=j-idx;
			ll cost=(ll)nb_a*X[idx]-sum(i,idx-1)+sum(idx+1,j)-(ll)nb_b*X[idx];
			if(cost<=B)ans=max(ans,j-i+1);
			else break;
		}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 0 ms 384 KB Output is correct
16 Correct 0 ms 384 KB Output is correct
17 Correct 0 ms 384 KB Output is correct
18 Correct 0 ms 384 KB Output is correct
19 Correct 0 ms 384 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 0 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 0 ms 384 KB Output is correct
24 Correct 0 ms 384 KB Output is correct
25 Correct 0 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 0 ms 384 KB Output is correct
28 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 0 ms 384 KB Output is correct
13 Correct 0 ms 384 KB Output is correct
14 Correct 0 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 1 ms 384 KB Output is correct
18 Correct 1 ms 384 KB Output is correct
19 Correct 1 ms 384 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 1 ms 384 KB Output is correct
24 Correct 1 ms 384 KB Output is correct
25 Correct 1 ms 384 KB Output is correct
26 Correct 1 ms 384 KB Output is correct
27 Correct 1 ms 384 KB Output is correct
28 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 512 KB Output is correct
2 Correct 3 ms 512 KB Output is correct
3 Correct 27 ms 1528 KB Output is correct
4 Correct 18 ms 1536 KB Output is correct
5 Correct 11 ms 896 KB Output is correct
6 Correct 11 ms 896 KB Output is correct
7 Correct 21 ms 1528 KB Output is correct
8 Correct 16 ms 1536 KB Output is correct
9 Correct 8 ms 896 KB Output is correct
10 Correct 8 ms 896 KB Output is correct
11 Correct 19 ms 1536 KB Output is correct
12 Correct 19 ms 1536 KB Output is correct
13 Correct 8 ms 896 KB Output is correct
14 Correct 8 ms 896 KB Output is correct
15 Correct 14 ms 1152 KB Output is correct
16 Correct 14 ms 1152 KB Output is correct
17 Correct 17 ms 1408 KB Output is correct
18 Correct 17 ms 1400 KB Output is correct
19 Correct 19 ms 1408 KB Output is correct
20 Correct 18 ms 1400 KB Output is correct