結果

問題 No.519 アイドルユニット
ユーザー ikdikd
提出日時 2017-11-27 17:16:19
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 49 ms / 1,000 ms
コード長 700 bytes
コンパイル時間 640 ms
コンパイル使用メモリ 86,092 KB
実行使用メモリ 68,916 KB
最終ジャッジ日時 2023-09-03 17:06:17
合計ジャッジ時間 2,504 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
68,916 KB
testcase_01 AC 49 ms
68,888 KB
testcase_02 AC 15 ms
19,724 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 3 ms
4,840 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 3 ms
5,376 KB
testcase_16 AC 3 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 2 ms
4,388 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 3 ms
4,872 KB
testcase_22 AC 3 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 5 ms
7,132 KB
testcase_25 AC 5 ms
7,480 KB
testcase_26 AC 5 ms
7,956 KB
testcase_27 AC 5 ms
7,168 KB
testcase_28 AC 5 ms
7,176 KB
testcase_29 AC 48 ms
68,508 KB
testcase_30 AC 48 ms
68,372 KB
testcase_31 AC 47 ms
68,332 KB
testcase_32 AC 48 ms
68,540 KB
testcase_33 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  int n; rd(n);
  auto a=new int[][](n, n);
  foreach(i; 0..n) a[i]=readln.split.to!(int[]);

  auto rec=new int[](1<<n);
  fill(rec, -1);
  int fun(int bit){
    if(bit==0) return 0;
    if(rec[bit]>=0) return rec[bit];
    int ret=0;
    foreach(i; 0..n)if(bit&(1<<i)){
      foreach(j; (i+1)..n)if(bit&(1<<j)){
        ret=max(ret, fun(bit^(1<<i)^(1<<j))+a[i][j]);
      }
      break;
    }
    return rec[bit]=ret;
  }

  writeln(fun((1<<n)-1));
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
0