Submission #242809

# Submission time Handle Problem Language Result Execution time Memory
242809 2020-06-29T10:42:45 Z godwind Boxes with souvenirs (IOI15_boxes) C++14
0 / 100
21 ms 31744 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];

priority_queue<long long> Q[N];
long long mod[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;
	int rem = 0;
	for (int r = 1; r <= n; ++r) {
		mod[rem] += L;
		Q[rem].push(-(pref[r - 1] - mod[rem]));
		uin(answer, suff[r] + (-Q[rem].top() + mod[rem] ));
		++rem;
		if (rem == k) --rem;
	}
	/*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 = 1; l <= n - c * k + 1; ++l) {
			uin(addit, pref[l - 1] + suff[l + c * k]);
		}
		uin(answer, cur + addit);
	}*/
    return answer;
}
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 31616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 31744 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 31616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 31616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 31616 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 21 ms 31616 KB Output isn't correct
2 Halted 0 ms 0 KB -