結果

問題 No.519 アイドルユニット
ユーザー 14番
提出日時 2017-05-28 22:31:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 93 ms / 1,000 ms
コード長 2,191 bytes
コンパイル時間 978 ms
コンパイル使用メモリ 115,672 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-10-03 03:47:37
合計ジャッジ時間 3,544 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #
プレゼンテーションモードにする

using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
class Program
{
public void Proc()
{
int IdolCount = int.Parse(Reader.ReadLine());
this.Aisho = new int[IdolCount, IdolCount];
for (int i = 0; i < IdolCount; i++)
{
int[] inpt = Reader.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
for (int j = 0; j < inpt.Length; j++)
{
this.Aisho[i, j] = inpt[j];
}
}
int ans = this.GetAns(0, 0);
Console.WriteLine(ans);
}
private int GetAns(int idx, long flags)
{
long key = (long)1 << idx;
if ((key & flags) > 0)
{
return GetAns(idx + 1, flags);
}
if (dic.ContainsKey(flags))
{
return dic[flags];
}
int ans = 0;
for (int i = idx + 1; i < Aisho.GetLength(0); i++)
{
long pairKey = (long)1 << i;
if ((flags & pairKey) > 0)
{
continue;
}
int ret = GetAns(idx + 1, flags + key + pairKey) + Aisho[idx, i];
ans = Math.Max(ret, ans);
}
dic[flags] = ans;
return ans;
}
private Dictionary<long, int> dic = new Dictionary<long, int>();
private int[,] Aisho;
public class Reader
{
public static bool IsDebug = false;
private static String PlainInput = @"
6
-1 14 29 35 39 8
14 -1 35 41 34 3
29 35 -1 14 21 21
35 41 14 -1 12 42
39 34 21 12 -1 28
8 3 21 42 28 -1
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
}
static void Main()
{
#if DEBUG
Reader.IsDebug = true;
#endif
Program prg = new Program();
prg.Proc();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0