結果

問題 No.54 Happy Hallowe'en
ユーザー nebukuro09nebukuro09
提出日時 2017-03-17 13:12:45
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 862 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 113,420 KB
実行使用メモリ 405,416 KB
最終ジャッジ日時 2023-09-03 12:28:48
合計ジャッジ時間 18,119 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 360 ms
58,812 KB
testcase_05 AC 666 ms
100,592 KB
testcase_06 AC 1,114 ms
155,444 KB
testcase_07 AC 1,777 ms
230,600 KB
testcase_08 AC 2,406 ms
307,456 KB
testcase_09 AC 3,274 ms
405,416 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2,272 ms
405,352 KB
testcase_13 AC 4,091 ms
405,392 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 2 ms
4,388 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;

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

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

int dp(int n, int v) {
    if (n >= N) return v;
    if (v >= T_max) return v;
    if (mem[n][v] >= 0) 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"();
    T_max = VT[N-1].t;
    mem = new int[][](N, T_max+1);
    foreach (i; 0..N) fill(mem[i], -1);
    dp(0, 0).writeln;
}
0