Submission #163603

# Submission time Handle Problem Language Result Execution time Memory
163603 2019-11-14T09:49:59 Z shenxy Boxes with souvenirs (IOI15_boxes) C++11
10 / 100
4 ms 504 KB
#include "boxes.h"
#include <algorithm>
#include <queue>
#include <utility>
using namespace std;
typedef pair<long long, int> ii;
long long delivery(int N, int K, int L, int p[]) {
	queue<ii> dp1, dp2;
	long long dptable[N];
	dp1.push(ii(0, -1));
	dp2.push(ii(2 * (L - p[0]), -1));
	for (int i = 0; i < N; ++i) {
		while (!dp1.empty() && dp1.front().second + K < i) dp1.pop();
		while (!dp2.empty() && dp2.front().second + K < i) dp2.pop();
		if (i >= K) dptable[i] = L + dptable[i - K];
		else dptable[i] = L;
		if (!dp1.empty()) dptable[i] = min(dptable[i], dp1.front().first + 2 * p[i]);
		if (!dp2.empty()) dptable[i] = min(dptable[i], dp2.front().first);
		if (i != N - 1) {
			while (!dp1.empty() && dp1.back().first >= dptable[i]) dp1.pop();
			dp1.push(ii(dptable[i], i));
			while (!dp2.empty() && dp2.back().first >= dptable[i] + 2 * (L - p[i + 1])) dp2.pop();
			dp2.push(ii(dptable[i] + 2 * (L - p[i + 1]), i));
		}
	}
	return dptable[N - 1];
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 252 KB Output is correct
3 Incorrect 2 ms 504 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Incorrect 2 ms 504 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Incorrect 2 ms 504 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 4 ms 256 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 252 KB Output is correct
10 Incorrect 2 ms 504 KB Output isn't correct
11 Halted 0 ms 0 KB -