結果

問題 No.54 Happy Hallowe'en
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 11:54:32
言語 D
(dmd 2.106.1)
結果
MLE  
実行時間 -
コード長 728 bytes
コンパイル時間 823 ms
コンパイル使用メモリ 112,888 KB
実行使用メモリ 813,536 KB
最終ジャッジ日時 2023-09-03 12:18:27
合計ジャッジ時間 5,630 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 MLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

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;

alias Tuple!(int , "v", int, "t") Okashi; 

int N;
Okashi[] VT;
int[int][10010] mem;

int dp(int n, int v) {
    if (n >= N) return v;
    if (v in mem[n]) return mem[n][v];
    if (v >= VT[n].t) return mem[n][v] = dp(n+1, v);
    else return mem[n][v] = max(dp(n+1, v), dp(n+1, v+VT[n].v));
    
}

void main() {
    N = readln.chomp.to!int;
    VT = new Okashi[](N);
    foreach (i; 0..N) {
        auto s = readln.split.map!(to!int);
        VT[i] = Okashi(s[0], s[1]);
    }

    VT.sort!"a.t < b.t"();
    dp(0, 0).writeln;
}
0