QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#753857#5590. Exponent ExchangeRico64WA 27ms82944kbC++231.2kb2024-11-16 13:44:532024-11-16 13:44:53

Judging History

This is the latest submission verdict.

  • [2024-11-16 13:44:53]
  • Judged
  • Verdict: WA
  • Time: 27ms
  • Memory: 82944kb
  • [2024-11-16 13:44:53]
  • Submitted

answer

#include <iostream>
#include <algorithm>
#include <cstdint>

using namespace std;

int b, n;
int dp[1000][2][100001];

int get(int i, int mode, int a) {
    if (i < 0 && a == 0 && mode == 0) return 0;
    if (i < 0) return INT32_MAX / 2;
    return dp[i][mode][a];
}

int main() {
    cin >> b >> n;
    int arr[n];
    for (int i = 0; i < n; ++i) cin >> arr[i];
    reverse(arr, arr + n);
    for (int i = 0; i < n; ++i) {
        for (int a = 0; a <= 100000; ++a) {
            dp[i][0][a] = INT32_MAX / 2;
            dp[i][1][a] = INT32_MAX / 2;
            // push down
            if (a - arr[i] >= 0) dp[i][0][a] = min(dp[i][0][a], get(i-1, 0, a - arr[i]));
            if (a - (arr[i] + 1) % b >= 0) dp[i][0][a] = min(dp[i][0][a], get(i-1, 1, a - (arr[i] + 1) % b));
            // push up
            dp[i][1][a] = min(dp[i][1][a], get(i - 1, 0, a) + (b - arr[i]));
            dp[i][1][a] = min(dp[i][1][a], get(i - 1, 1, a) + (b - arr[i] - 1));
        }
    }
    int res = INT32_MAX;
    for (int mode = 0; mode < 2; ++mode) {
        for (int a = 0; a <= 100000; ++a) {
            res = min(res, max(dp[n - 1][mode][a], a));
        }
    }
    cout << res << endl;

    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 9340kb

input:

10 5
4 2 7 8 6

output:

7

result:

ok single line: '7'

Test #2:

score: -100
Wrong Answer
time: 27ms
memory: 82944kb

input:

2 100
1 1 1 1 0 0 1 1 1 0 1 1 1 0 0 1 0 0 1 0 0 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 0 1 0 1 0 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 1 1 1 0 1 1 0 1 1 0 0 0 0 1 1 1

output:

16

result:

wrong answer 1st lines differ - expected: '19', found: '16'