답안 #133027

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
133027 2019-07-20T05:18:52 Z tinjyu 쌀 창고 (IOI11_ricehub) C++14
100 / 100
20 ms 2640 KB
#include "ricehub.h"
#include <iostream>
using namespace std;
long long int sum[100005],a[100005][2];
int besthub(int R, int L, int X[], long long B)
{
	long long int now=0;
	sum[0]=X[0];
	for(int i=1;i<R;i++)
	{
		sum[i]=sum[i-1]+X[i];
	}
	long long int s=0,e=0;
	long long int ans=0;
	while(s<=e && e<R)
	{
		long long int mid=(s+e)/2;
		long long int tmp=(X[mid]*(mid-s)-(sum[mid-1]-sum[s-1])+(sum[e]-sum[mid])-X[mid]*(e-mid));
		if(tmp<=B)
		{
			ans=max(ans,e-s+1);
			e++;
		}
		else s++;
	}
  	return ans;
}

Compilation message

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:7:16: warning: unused variable 'now' [-Wunused-variable]
  long long int now=0;
                ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 344 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 3 ms 504 KB Output is correct
24 Correct 3 ms 376 KB Output is correct
25 Correct 3 ms 504 KB Output is correct
26 Correct 3 ms 504 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 632 KB Output is correct
2 Correct 5 ms 632 KB Output is correct
3 Correct 18 ms 1484 KB Output is correct
4 Correct 18 ms 2512 KB Output is correct
5 Correct 9 ms 1272 KB Output is correct
6 Correct 9 ms 1272 KB Output is correct
7 Correct 16 ms 2296 KB Output is correct
8 Correct 16 ms 2296 KB Output is correct
9 Correct 8 ms 1272 KB Output is correct
10 Correct 9 ms 1272 KB Output is correct
11 Correct 20 ms 2552 KB Output is correct
12 Correct 20 ms 2640 KB Output is correct
13 Correct 10 ms 1272 KB Output is correct
14 Correct 10 ms 1272 KB Output is correct
15 Correct 15 ms 2040 KB Output is correct
16 Correct 15 ms 2040 KB Output is correct
17 Correct 18 ms 2296 KB Output is correct
18 Correct 18 ms 2296 KB Output is correct
19 Correct 19 ms 2424 KB Output is correct
20 Correct 19 ms 2424 KB Output is correct