QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#800714 | #9848. Paid Leave | GSYL# | WA | 0ms | 3624kb | C++14 | 1.3kb | 2024-12-06 14:56:57 | 2024-12-06 14:56:57 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 0x3f3f3f3f3f3f3f3f;
signed main() {
int n, m, x, y; cin >> n >> m >> x >> y;
vector<int> a(m + 1, 0);
for (int i = 1; i <= m; i++) {
cin >> a[i];
}
a.push_back(n + 1);
vector<vector<int>> dp(m + 2, vector<int>(2, INF));
dp[0][0] = 0;
for (int i = 1; i <= m + 1; i++) {
int d = a[i] - a[i - 1] - 1;
int tmp = d % (y + 2);
// y-x first
if (tmp <= y - x) {
dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2);
dp[i][0] = min(dp[i][0], dp[i - 1][1] + d / (y + 2) * 2);
}
else if (tmp - y + x - 1 <= y - x) {
dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2 + 1);
dp[i][0] = min(dp[i][0], dp[i - 1][1] + d / (y + 2) * 2 + 1);
}
else {
dp[i][1] = min(dp[i][1], dp[i - 1][0] + d / (y + 2) * 2 + 1);
dp[i][1] = min(dp[i][1], dp[i - 1][1] + d / (y + 2) * 2 + 1);
}
// x first
if (tmp <= x) {
dp[i][1] = min(dp[i][1], dp[i - 1][0] + d / (y + 2) * 2);
}
else {
dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2 + 1);
}
}
cout << min(dp[m + 1][0], dp[m + 1][1]) << '\n';
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3624kb
input:
8 0 3 3
output:
2
result:
ok single line: '2'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
11 1 2 4 6
output:
2
result:
ok single line: '2'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
17 2 5 7 6 12
output:
1
result:
ok single line: '1'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3624kb
input:
30 2 5 6 7 21
output:
5
result:
ok single line: '5'
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3596kb
input:
38 1 6 6 20
output:
9
result:
wrong answer 1st lines differ - expected: '8', found: '9'