답안 #111653

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
111653 2019-05-16T00:44:44 Z ly20 쌀 창고 (IOI11_ricehub) C++14
100 / 100
25 ms 4344 KB
#include<bits/stdc++.h>
#define debug(args...) //fprintf(stderr,args)
using namespace std;
const int MAXN=112345;
const long long MAXL=1123456789;
long long se[MAXN],sd[MAXN],v[MAXN];
int besthub(int r, int l, int x[], long long b)
{
	for(int i=0;i<r;i++)v[i]=x[i];
	se[0]=v[0];
	debug("esquerda:\nse[%d]=%lld\n",0,se[0]);
	for(int i=1;i<r;i++)
	{
		se[i]=se[i-1]+v[i];
		debug("se[%d]=%lld\n",i,se[i]);
	}
	debug("\n");
	sd[r-1]=l-v[r-1];
	for(int i=r-2;i>=0;i--)sd[i]=sd[i+1]+(l-v[i]);
	debug("direita:\n");
	for(int i=0;i<r;i++)
	{
		debug("sd[%d]=%lld\n",i,sd[i]);
	}
	debug("\n");
	int resp=0;
	int ini=0,fim=0;
	while(fim<r)
	{
		int m=(ini+fim)/2;
		long long cont=0;
		if(m==0)
		{
			cont+=v[fim]-v[ini];
		}
		else if(m!=r-1)
		{
			cont+=se[fim]-se[m-1];
			cont-=(fim-m+1)*v[m];
			cont+=sd[ini]-sd[m+1];
			cont-=(m-ini+1)*(l-v[m]);
		}
		debug("ini=%d fim=%d cost=%lld\n",ini,fim,cont);
		if(cont<=b)
		{
			resp=max(resp,fim-ini+1);
			fim++;
		}
		else ini++;
	}
	return resp;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 3 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 3 ms 356 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 3 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 2 ms 512 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 2 ms 356 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
21 Correct 2 ms 384 KB Output is correct
22 Correct 2 ms 384 KB Output is correct
23 Correct 2 ms 384 KB Output is correct
24 Correct 2 ms 384 KB Output is correct
25 Correct 2 ms 384 KB Output is correct
26 Correct 2 ms 384 KB Output is correct
27 Correct 3 ms 384 KB Output is correct
28 Correct 2 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 3 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 3 ms 320 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 3 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 3 ms 384 KB Output is correct
20 Correct 3 ms 384 KB Output is correct
21 Correct 5 ms 512 KB Output is correct
22 Correct 4 ms 512 KB Output is correct
23 Correct 4 ms 512 KB Output is correct
24 Correct 3 ms 512 KB Output is correct
25 Correct 3 ms 512 KB Output is correct
26 Correct 4 ms 512 KB Output is correct
27 Correct 3 ms 512 KB Output is correct
28 Correct 3 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 896 KB Output is correct
2 Correct 5 ms 1024 KB Output is correct
3 Correct 22 ms 4088 KB Output is correct
4 Correct 20 ms 4344 KB Output is correct
5 Correct 10 ms 2048 KB Output is correct
6 Correct 9 ms 2048 KB Output is correct
7 Correct 16 ms 3840 KB Output is correct
8 Correct 15 ms 3840 KB Output is correct
9 Correct 8 ms 2020 KB Output is correct
10 Correct 10 ms 2048 KB Output is correct
11 Correct 17 ms 4088 KB Output is correct
12 Correct 19 ms 4096 KB Output is correct
13 Correct 9 ms 2048 KB Output is correct
14 Correct 10 ms 2048 KB Output is correct
15 Correct 16 ms 3192 KB Output is correct
16 Correct 17 ms 3204 KB Output is correct
17 Correct 17 ms 3712 KB Output is correct
18 Correct 25 ms 3704 KB Output is correct
19 Correct 17 ms 3968 KB Output is correct
20 Correct 20 ms 3960 KB Output is correct