結果
問題 |
No.54 Happy Hallowe'en
|
ユーザー |
|
提出日時 | 2017-03-17 11:54:32 |
言語 | D (dmd 2.109.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 728 bytes |
コンパイル時間 | 875 ms |
コンパイル使用メモリ | 128,980 KB |
実行使用メモリ | 812,540 KB |
最終ジャッジ日時 | 2024-06-12 18:22:42 |
合計ジャッジ時間 | 5,479 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 MLE * 1 -- * 14 |
ソースコード
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; }