結果

問題 No.710 チーム戦
ユーザー nebukuro09nebukuro09
提出日時 2018-06-30 00:16:01
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 59 ms / 3,000 ms
コード長 833 bytes
コンパイル時間 662 ms
コンパイル使用メモリ 108,204 KB
実行使用メモリ 5,088 KB
最終ジャッジ日時 2023-09-03 20:28:52
合計ジャッジ時間 3,152 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 59 ms
4,376 KB
testcase_03 AC 58 ms
4,376 KB
testcase_04 AC 59 ms
4,384 KB
testcase_05 AC 57 ms
4,376 KB
testcase_06 AC 58 ms
4,376 KB
testcase_07 AC 58 ms
4,376 KB
testcase_08 AC 59 ms
4,380 KB
testcase_09 AC 57 ms
5,088 KB
testcase_10 AC 58 ms
4,380 KB
testcase_11 AC 58 ms
4,380 KB
testcase_12 AC 58 ms
4,380 KB
testcase_13 AC 58 ms
4,376 KB
testcase_14 AC 59 ms
4,376 KB
testcase_15 AC 58 ms
4,380 KB
testcase_16 AC 58 ms
4,380 KB
testcase_17 AC 57 ms
4,380 KB
testcase_18 AC 57 ms
4,376 KB
testcase_19 AC 58 ms
4,380 KB
testcase_20 AC 58 ms
4,380 KB
testcase_21 AC 57 ms
4,376 KB
testcase_22 AC 55 ms
4,376 KB
testcase_23 AC 59 ms
4,380 KB
testcase_24 AC 55 ms
4,756 KB
testcase_25 AC 4 ms
4,376 KB
testcase_26 AC 4 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 = 100001;
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