Submission #242792

# Submission time Handle Problem Language Result Execution time Memory
242792 2020-06-29T10:23:32 Z godwind Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
5 ms 384 KB
#include "boxes.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <set>
#include <map>
#include <queue>
#include <cstring>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <functional>

using namespace std;

template<typename T> void uin(T &a, T b) {
	if (b < a) {
		a = b;
	}
}

const int N = 1000 * 1000 + 7; // for now
const long long INF = 1e18 + 228;

long long pref[N], suff[N];

long long delivery(int n, int k, int L, int p[]) {
	for (int i = 1; i <= n; ++i) {
		pref[i] = 2LL * p[i - 1];
		if (i > k) {
			pref[i] += pref[i - k];
		}
	}
	for (int i = n; i; --i) {
		suff[i] = 2LL * (L - p[i - 1]);
		if (i + k <= n) {
			suff[i] += suff[i + k];
		}
	}
	long long answer = INF;
	for (int c = 0; c <= (n + k - 1) / k; ++c) {
		long long cur = (long long)L * (long long)c;
		long long addit = INF;
		for (int l = max(1, n / 2 - c * k); l <= min(n - c * k + 1, n / 2 + c * k); ++l) {
			uin(addit, pref[l - 1] + suff[l + c * k]);
		}
		uin(answer, cur + addit);
	}
    return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Incorrect 4 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -