답안 #117130

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
117130 2019-06-15T00:11:15 Z Lawliet Shortcut (IOI16_shortcut) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#include "shortcut.h"

//colocar grader

#define MAX 1000010
#define INF 1000000000000000000LL

using namespace std;
typedef pair<int,int> pii;
typedef long long int lli;

int N, C;

lli L[MAX];
lli D[MAX];
lli sL[MAX];
lli mxLeft[MAX];
lli mxRight[MAX];

void init()
{
	for(int g = 1 ; g <= N - 1 ; g++)
		sL[g] = sL[g - 1] + L[g];

	for(int g = 1 ; g <= N ; g++)
		mxLeft[g] = max(mxLeft[g - 1] + L[g - 1] , D[g]);

	for(int g = N ; g >= 1 ; g--)
		mxRight[g] = max(mxRight[g + 1] + L[g] , D[g]);
}

lli dist(int i, int j) { return sL[j - 1] - sL[i - 1]; }

long long int find_shortcut(int n, std::vector<int> l, std::vector<int> d, int c)
{
	for(int g = 0 ; g < n - 1 ; g++) L[g + 1] = l[g];
	for(int g = 0 ; g < n ; g++) D[g + 1] = d[g];

	init();

	lli ans = INF;

	for(int i = 1 ; i <= n ; i++)
	{
		for(int j = i + 1 ; j <= n ; j++)
		{
			lli ansIJ = -1;

			//if(i != 2 || j != 3) continue;

			//printf("i = %d  j = %d\n",i,j);

			lli cnt = dist(i , j);

			for(int myPoint = i ; myPoint <= j ; myPoint++)
			{
				lli distance;

				if(myPoint != i)
				{
					distance = dist(i , myPoint);
					distance = min(distance , c + cnt - distance);

					ansIJ = max(ansIJ , mxLeft[i] + distance + D[myPoint] );

					//printf("my = %d      %lld %lld %lld\n",myPoint,mxLeft[i], distance,D[myPoint]);
				}

				for(int g = i + 1 ; g < j ; g++)
				{
					if(g == myPoint) continue;

					distance = abs( dist(g , myPoint) );
					distance = min(distance , c + cnt - distance);

					ansIJ = max(ansIJ , D[g] + distance + D[myPoint] );
				}

				if(myPoint != j)
				{
					distance = dist(myPoint , j);
					distance = min(distance , c + cnt - distance);

					ansIJ = max(ansIJ , D[myPoint] + distance + mxRight[j] );

					//printf("- my = %d      %lld %lld %lld\n",myPoint,mxRight[j], distance,D[myPoint]);
				}
			}

			ansIJ = max(ansIJ , mxLeft[i - 1] + L[i - 1] + D[i]);
			ansIJ = max(ansIJ , mxRight[j + 1] + L[j] + D[j]);
			ansIJ = max(ansIJ , min(cnt , (long long int) c) + mxRight[j] + mxLeft[i]);

			//printf("------------------------------ i = %d  j = %d     %d\n",i,j,ansIJ);

			ans = min(ans , ansIJ);
		}
	}

	return ans;
}

/*int main()
{
	scanf("%d %d",&N,&C);

	vector<int> dd(N), ll(N - 1);

	for(int g = 0 ; g < N - 1 ; g++)
		scanf("%d",&ll[g]);

	for(int g = 0 ; g < N ; g++)
		scanf("%d",&dd[g]);

	printf("%lld\n",find_shortcut(N , ll , dd , C));
}*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB n = 4, incorrect answer: jury 80 vs contestant 30
2 Halted 0 ms 0 KB -