結果

問題 No.158 奇妙なお使い
ユーザー nebukuro09nebukuro09
提出日時 2017-03-23 10:54:37
言語 D
(dmd 2.105.2)
結果
RE  
実行時間 -
コード長 1,057 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 91,532 KB
実行使用メモリ 44,728 KB
最終ジャッジ日時 2023-09-03 12:36:26
合計ジャッジ時間 4,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
42,904 KB
testcase_01 AC 36 ms
43,188 KB
testcase_02 AC 32 ms
43,628 KB
testcase_03 AC 32 ms
43,152 KB
testcase_04 AC 854 ms
44,728 KB
testcase_05 AC 32 ms
42,944 KB
testcase_06 RE -
testcase_07 AC 32 ms
43,100 KB
testcase_08 AC 32 ms
42,952 KB
testcase_09 AC 32 ms
43,196 KB
testcase_10 AC 34 ms
43,660 KB
testcase_11 AC 32 ms
42,900 KB
testcase_12 AC 31 ms
42,672 KB
testcase_13 AC 32 ms
43,860 KB
testcase_14 AC 35 ms
43,164 KB
testcase_15 AC 46 ms
43,144 KB
testcase_16 RE -
testcase_17 RE -
testcase_18 AC 37 ms
42,880 KB
testcase_19 AC 32 ms
42,864 KB
testcase_20 AC 36 ms
43,088 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 33 ms
43,660 KB
testcase_24 AC 33 ms
43,164 KB
testcase_25 AC 32 ms
44,676 KB
testcase_26 AC 37 ms
43,144 KB
testcase_27 AC 32 ms
43,616 KB
testcase_28 AC 84 ms
44,216 KB
testcase_29 AC 31 ms
43,920 KB
testcase_30 AC 90 ms
42,964 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[][][](10, 100, 10000);
    foreach (i; 0..10) foreach (j; 0..100) foreach (k; 0..10000) mem[i][j][k] = -1;
    dp(a, b, c).writeln;
}
0