結果
| 問題 |
No.54 Happy Hallowe'en
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-17 13:12:45 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 862 bytes |
| コンパイル時間 | 928 ms |
| コンパイル使用メモリ | 128,716 KB |
| 実行使用メモリ | 404,848 KB |
| 最終ジャッジ日時 | 2024-06-12 18:23:33 |
| 合計ジャッジ時間 | 14,354 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 WA * 2 |
ソースコード
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;
}