Submission #1084892

#TimeUsernameProblemLanguageResultExecution timeMemory
1084892the_coding_poohBoxes with souvenirs (IOI15_boxes)C++14
50 / 100
121 ms26272 KiB
#include "boxes.h"

#include <bits/stdc++.h>
#define uwu return ans;

using namespace std;

const int SIZE = 1e3 + 5;

long long calc(int l, int r, int L){
	return min({L, 2 * r, 2 * (L - l)});
}

const long long INF = 1e18;

long long dp[SIZE];

long long delivery(int N, int K, int L, int p[]) {
	long long ans = INF;
	vector <int> pos;
	for(int i = 0; i < N; i++){
		pos.push_back(p[i]);
	}
	pos.push_back(0);
	sort(pos.begin(), pos.end());

	for(int i = 1; i <= N; i++){
		dp[i] = INF;
		for(int j = max(i - K, 0); j < i; j++){
			dp[i] = min(dp[i], dp[j] + calc(pos[j + 1], pos[i],  L));
		}
	}
	ans = dp[N];
	uwu
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...