답안 #259501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
259501 2020-08-07T23:38:07 Z amiratou 쌀 창고 (IOI11_ricehub) C++14
68 / 100
22 ms 2304 KB
#include "ricehub.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
 
ll cum[100005],tab[100005];
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)
	{
		tab[i]=X[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=nb_a*X[idx]-sum(i,idx-1)+sum(idx+1,j)-nb_b*X[idx];
			if(cost<=B)ans=max(ans,j-i+1);
			else break;
		}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 384 KB Output is correct
12 Correct 1 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 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 1 ms 384 KB Output is correct
22 Correct 0 ms 384 KB Output is correct
23 Correct 1 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 1 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 1 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 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 1 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 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 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 512 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 768 KB Output is correct
2 Correct 5 ms 768 KB Output is correct
3 Correct 18 ms 2296 KB Output is correct
4 Correct 17 ms 2304 KB Output is correct
5 Correct 7 ms 1280 KB Output is correct
6 Correct 8 ms 1292 KB Output is correct
7 Correct 15 ms 2304 KB Output is correct
8 Correct 15 ms 2304 KB Output is correct
9 Correct 8 ms 1408 KB Output is correct
10 Correct 7 ms 1280 KB Output is correct
11 Correct 19 ms 2304 KB Output is correct
12 Correct 22 ms 2304 KB Output is correct
13 Correct 8 ms 1280 KB Output is correct
14 Correct 8 ms 1280 KB Output is correct
15 Correct 14 ms 1792 KB Output is correct
16 Correct 14 ms 1792 KB Output is correct
17 Correct 17 ms 2048 KB Output is correct
18 Incorrect 17 ms 2048 KB Output isn't correct
19 Halted 0 ms 0 KB -