結果
問題 | No.519 アイドルユニット |
ユーザー |
|
提出日時 | 2017-06-10 15:28:47 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 69 ms / 1,000 ms |
コード長 | 789 bytes |
コンパイル時間 | 747 ms |
コンパイル使用メモリ | 120,896 KB |
実行使用メモリ | 69,408 KB |
最終ジャッジ日時 | 2024-06-12 19:56:14 |
合計ジャッジ時間 | 2,167 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
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; void main() { auto N = readln.chomp.to!int; auto F = N.iota.map!(_ => readln.split.map!(to!int).array).array; auto dp = new int[](1 << N); fill(dp, -1); dp[0] = 0; for (int mask = 0; mask < (1 << N); mask++) { if (dp[mask] < 0) continue; int i = bsf(~mask); foreach (j; i+1..N) { if (!(mask & (1 << j))) { dp[mask | (1 << i) | (1 << j)] = max(dp[mask | (1 << i) | (1 << j)], dp[mask] + F[i][j]); } } } dp[(1 << N) - 1].writeln; }