結果

問題 No.158 奇妙なお使い
ユーザー nebukuro09nebukuro09
提出日時 2017-03-23 10:55:24
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 858 ms / 5,000 ms
コード長 1,057 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 91,448 KB
実行使用メモリ 49,028 KB
最終ジャッジ日時 2023-09-03 12:36:36
合計ジャッジ時間 3,923 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
47,988 KB
testcase_01 AC 38 ms
47,628 KB
testcase_02 AC 34 ms
47,516 KB
testcase_03 AC 35 ms
47,492 KB
testcase_04 AC 858 ms
49,028 KB
testcase_05 AC 34 ms
47,512 KB
testcase_06 AC 34 ms
47,984 KB
testcase_07 AC 34 ms
47,836 KB
testcase_08 AC 35 ms
48,020 KB
testcase_09 AC 35 ms
47,984 KB
testcase_10 AC 35 ms
48,628 KB
testcase_11 AC 35 ms
47,264 KB
testcase_12 AC 34 ms
47,296 KB
testcase_13 AC 34 ms
48,036 KB
testcase_14 AC 38 ms
47,568 KB
testcase_15 AC 49 ms
47,248 KB
testcase_16 AC 44 ms
47,260 KB
testcase_17 AC 108 ms
47,780 KB
testcase_18 AC 40 ms
47,308 KB
testcase_19 AC 35 ms
47,360 KB
testcase_20 AC 39 ms
47,976 KB
testcase_21 AC 35 ms
47,480 KB
testcase_22 AC 35 ms
48,364 KB
testcase_23 AC 36 ms
48,516 KB
testcase_24 AC 34 ms
48,024 KB
testcase_25 AC 34 ms
47,052 KB
testcase_26 AC 39 ms
47,508 KB
testcase_27 AC 36 ms
47,560 KB
testcase_28 AC 87 ms
47,832 KB
testcase_29 AC 35 ms
47,292 KB
testcase_30 AC 93 ms
48,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

int[2] cost, A, B, C;
int[][][] mem;

int dp(int a, int b, int c) {
    if (mem[a][b][c] >= 0) return mem[a][b][c];
    int ret = 0;
    foreach (i; 0..2) {
        foreach (j; 0..a+1) {
            foreach (k; 0..b+1) {
                int oneyen = cost[i] - j * 1000 - k * 100;
                if (oneyen < 0) break;
                if (oneyen > c) continue;
                ret = max(ret, dp(a-j+A[i], b-k+B[i], c-oneyen+C[i]) + 1);
            }
        }
    }
    return mem[a][b][c] = ret;
}

void main() {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    scanf("%d", &cost[0]);
    scanf("%d %d %d", &A[0], &B[0], &C[0]);
    scanf("%d", &cost[1]);
    scanf("%d %d %d", &A[1], &B[1], &C[1]);
    mem = new int[][][](11, 101, 10001);
    foreach (i; 0..11) foreach (j; 0..101) foreach (k; 0..10001) mem[i][j][k] = -1;
    dp(a, b, c).writeln;
}
0