結果

問題 No.710 チーム戦
ユーザー nebukuro09nebukuro09
提出日時 2018-06-30 00:10:59
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 713 ms
コンパイル使用メモリ 108,228 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-03 20:28:45
合計ジャッジ時間 2,096 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 8 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 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, std.bitmanip;

immutable int MAX = 10001;
immutable int INF = 1 << 29;

void main() {
    auto N = readln.chomp.to!int;
    auto V = N.iota.map!(_ => readln.split.map!(to!int).array).array;
    auto dp = new int[][](2, MAX);
    fill(dp[0], INF);
    dp[0][0] = 0;

    int cur = 0, tar = 1;
    foreach (i; 0..N) {
        fill(dp[tar], INF);
        foreach (j; 0..MAX) {
            dp[tar][j] = min(dp[tar][j], dp[cur][j] + V[i][1]);
            if (j + V[i][0] < MAX)
                dp[tar][j+V[i][0]] = min(dp[tar][j+V[i][0]], dp[cur][j]);
        }
        swap(cur, tar);
    }

    MAX.iota.map!(i => max(i, dp[cur][i])).reduce!min.writeln;
}
0