Submission #129188

# Submission time Handle Problem Language Result Execution time Memory
129188 2019-07-11T19:43:36 Z joseacaz Boxes with souvenirs (IOI15_boxes) C++17
0 / 100
4 ms 504 KB
#include "boxes.h"
#include <bits/stdc++.h>
#define MAXN 1000006
#define INF (1LL << 62LL)

using namespace std;
typedef long long ll;

int N, K, L, lbound, rbound;
ll DP[MAXN], pre[MAXN], cost;
vector < int > P;

ll delivery ( int _n, int _k, int _l, int _p[] )
{
	N = _n, K = _k, L = _l;
	P.push_back ( 0 );
	for ( int i = 0; i < N; i++ )
		P.push_back ( _p[i] );
	P.push_back ( L );
	
	for ( int i = 1; i <= N + 1; i++ )
	{
		pre[i] = pre[i - 1] + (P[i] - P[i - 1]);
		if ( 2 * pre[i] < L )
			lbound = i;
	}

	for ( int i = N; i >= 1; i-- )
		if ( 2 * (pre[N + 1] - pre[i]) < L )
			rbound = i;

	if ( lbound > rbound )
		lbound = (lbound + rbound) / 2, rbound = lbound + 1;
	
	for ( int i = N; i >= 1; i-- )
	{
		DP[i] = INF;
		for ( int k = 1; k <= K; k++ )
		{
			if ( i + k <= N + 1 )
			{
				if ( i + k - 1 <= lbound )
					cost = 2LL * pre[i + k - 1];
				else if ( i >= rbound )
					cost = 2LL * (pre[N + 1] - pre[i]);
				else
					cost = L;

				DP[i] = min ( DP[i], DP[i + k] + cost );
			}
		}
	}

	return DP[1];
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Incorrect 4 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 380 KB Output isn't correct
2 Halted 0 ms 0 KB -