結果

問題 No.2366 登校
ユーザー Carpenters-CatCarpenters-Cat
提出日時 2021-06-29 22:17:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,044 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 67,780 KB
実行使用メモリ 24,952 KB
最終ジャッジ日時 2023-09-22 05:08:31
合計ジャッジ時間 1,821 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 7 ms
15,780 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 23 ms
23,040 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

//嘘解法が通らないか確認
#include <iostream>
#include <cassert>
using namespace std;
using ll = long long;
int main () {
    int N, M, K, T;
    cin >> N >> M >> K >> T;
    assert(1 <= N && N <= 80);
    assert(1 <= M && M <= 80);
    assert(0 <= K && K <= N * M - 2);
    assert(1 <= T <= (int)1e9);
    ll C[88][88];
    ll D[88][88];
    for (int i = 0; i < N; i ++) {
        for (int j = 0; j < M; j ++) {
            C[i][j] = D[i][j] = 0;
        }
    }
    for (int i = 0; i < K; i ++) {
        int a, b;
        cin >> a >> b;
        assert(1 <= a && a <= N);
        assert(1 <= b && b <= M);
        assert(2 < a + b && a + b < N + M);
        a --;
        b --;
        assert(C[a][b] == 0);
        cin >> C[a][b] >> D[a][b];
    }
    if (T > N + M - 1) {
        cout << "0" << endl;
        return 0;
    }
    ll dp[406][88][88];
    ll INF = (ll)1e18;
    for (int i = 0; i <= (N + M) * 2 - 1; i ++) {
        for (int j = 0; j < N; j ++) {
            for (int k = 0; k < M; k ++) {
                dp[i][j][k] = INF;
            }
        }
    }
    for (int i = N + M - 1; i <= (N + M) * 2 - 1; i ++) {
        dp[0][0][i] = 0;
    }
    for (int i = 0; i < N; i ++) {
        for (int j = 0; j < M; j ++) {
            if (i + j == 0) {
                continue;
            }
            for (int k = (N + M) * 2 - 1; k >= 0; k --) {
                if (k > 0) {
                    if (i > 0) {
                        dp[k][i][j] = min(dp[k][i][j], dp[k - 1][i - 1][j]);
                    }
                    if (j > 0) {
                        dp[k][i][j] = min(dp[k][i][j], dp[k - 1][i][j - 1]);
                    }
                }
                if (C[i][j] > 1) {
                    int kj = max(0ll, k - C[i][j] + 1);
                    dp[kj][i][j] = min(dp[kj][i][j], dp[k][i][j] + D[i][j]);
                }
            }
        }
    }
    ll ans = INF;
    for (int i = 0; i <= T + N + M - 1; i ++) {
        ans = min(ans, dp[i][N - 1][M - 1]);
    }
    cout << ans << endl;
}
0