QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#123883 | #2785. Boxes with souvenirs | valerikk# | 0 | 1ms | 5856kb | C++17 | 1.1kb | 2023-07-13 21:37:28 | 2024-07-04 00:38:06 |
Judging History
answer
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef long long ll;
const int N = 1e7 + 7;
int n, k, l, p[N];
ll dp[N];
}
long long delivery(int grdn, int grdk, int grdl, int grdp[]) {
n = grdn;
k = grdk;
l = grdl;
for (int i = 0; i < n; ++i) {
p[i] = grdp[i];
}
memset(dp, 0x3f, (n + 1) * sizeof dp[0]);
dp[0] = 0;
deque<int> q, q1;
for (int i = 0; i < n; ++i) {
while (!q.empty() && dp[q.back()] - 2 * p[q.back()] >= dp[i] - 2 * p[i]) {
q.pop_back();
}
q.push_back(i);
if (i - k >= 0 && q.front() == i - k) {
q.pop_front();
}
while (!q1.empty() && dp[q1.back()] >= dp[i]) {
q1.pop_back();
}
q1.push_back(i);
if (i - k >= 0 && q1.front() == i - k) {
q1.pop_back();
}
dp[i + 1] = min(dp[i + 1], dp[q.front()] + 2 * (l - p[q.front()]));
dp[i + 1] = min(dp[i + 1], dp[q1.front()] + 2 * p[i]);
}
return dp[n];
// for (int i = 0; i < n; ++i) {
// for (int j = i; j < min(i + k, n); ++j) {
// int cost = min({2 * p[j], 2 * (l - p[i]), l});
// dp[j + 1] = min(dp[j + 1], dp[i] + cost);
// }
// }
// return dp[n];
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 10
Accepted
time: 1ms
memory: 5704kb
input:
1 1 1000000000 210758687
output:
421517374
result:
ok single line: '421517374'
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 5856kb
input:
1000 1 1000000000 1808509 2182084 3015527 4447494 7769779 8792029 9883237 12829051 12902231 13338930 16688684 16992515 17866419 19063417 20124997 20125047 20514891 20917910 24004241 25917774 30411202 34419407 34944244 36371532 36402573 39271076 39612282 40912226 41119528 41176691 42741034 42801382 4...
output:
1998471008
result:
wrong answer 1st lines differ - expected: '511681980406', found: '1998471008'
Subtask #2:
score: 0
Wrong Answer
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 5780kb
input:
1000 1000 1000 0 0 1 2 3 3 4 5 5 6 6 7 8 8 8 9 10 11 11 11 12 13 13 13 14 14 15 16 17 17 17 18 20 20 21 21 24 25 25 26 30 31 34 34 35 38 40 43 44 46 46 46 47 47 51 52 52 52 55 56 58 62 64 65 67 68 69 72 73 75 76 77 78 79 79 80 83 84 85 85 86 86 87 88 88 88 92 92 92 95 95 96 98 98 99 99 100 100 101 1...
output:
1984
result:
wrong answer 1st lines differ - expected: '1000', found: '1984'
Subtask #3:
score: 0
Wrong Answer
Test #15:
score: 0
Wrong Answer
time: 1ms
memory: 5716kb
input:
10 5 5 0 0 0 0 0 1 3 3 3 4
output:
6
result:
wrong answer 1st lines differ - expected: '5', found: '6'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
0%