結果
問題 | No.710 チーム戦 |
ユーザー |
|
提出日時 | 2018-06-30 00:10:59 |
言語 | D (dmd 2.109.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 832 bytes |
コンパイル時間 | 1,024 ms |
コンパイル使用メモリ | 121,904 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-13 01:16:52 |
合計ジャッジ時間 | 1,846 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 3 WA * 22 |
ソースコード
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 = 10001;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;}