QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#800795#9848. Paid LeaveGSYL#WA 1ms3824kbC++141.7kb2024-12-06 15:41:152024-12-06 15:41:17

Judging History

你现在查看的是最新测评结果

  • [2024-12-06 15:41:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3824kb
  • [2024-12-06 15:41:15]
  • 提交

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);
            dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2 + 2);
            dp[i][0] = min(dp[i][0], dp[i - 1][1] + d / (y + 2) * 2 + 2);
        }
        // x first
        if (tmp <= y - x) {
            dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2);
        }
        else if (tmp <= x) {
            dp[i][1] = min(dp[i][1], dp[i - 1][0] + d / (y + 2) * 2);
            dp[i][0] = min(dp[i][0], dp[i - 1][0] + d / (y + 2) * 2 + 1);
        }
        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: 1ms
memory: 3660kb

input:

8 0 3 3


output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3824kb

input:

11 1 2 4
6

output:

2

result:

ok single line: '2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

17 2 5 7
6 12

output:

1

result:

ok single line: '1'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

30 2 5 6
7 21

output:

5

result:

ok single line: '5'

Test #5:

score: -100
Wrong Answer
time: 0ms
memory: 3556kb

input:

38 1 6 6
20

output:

9

result:

wrong answer 1st lines differ - expected: '8', found: '9'