結果

問題 No.158 奇妙なお使い
コンテスト
ユーザー nebukuro09
提出日時 2017-03-23 10:49:37
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
TLE  
実行時間 -
コード長 865 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 639 ms
コンパイル使用メモリ 88,388 KB
実行使用メモリ 16,196 KB
最終ジャッジ日時 2026-03-05 14:09:10
合計ジャッジ時間 140,125 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 TLE * 22
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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) {
    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 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]);
    dp(a, b, c).writeln;
}
0