結果

問題 No.519 アイドルユニット
ユーザー mbanmban
提出日時 2017-05-29 12:05:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 145 ms / 1,000 ms
コード長 1,723 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 113,956 KB
実行使用メモリ 96,168 KB
最終ジャッジ日時 2024-04-14 06:38:10
合計ジャッジ時間 6,714 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 141 ms
92,304 KB
testcase_01 AC 145 ms
92,164 KB
testcase_02 AC 122 ms
92,028 KB
testcase_03 AC 114 ms
92,328 KB
testcase_04 AC 117 ms
93,880 KB
testcase_05 AC 114 ms
94,252 KB
testcase_06 AC 113 ms
92,044 KB
testcase_07 AC 113 ms
94,328 KB
testcase_08 AC 114 ms
92,080 KB
testcase_09 AC 113 ms
91,956 KB
testcase_10 AC 113 ms
91,952 KB
testcase_11 AC 115 ms
91,824 KB
testcase_12 AC 113 ms
92,044 KB
testcase_13 AC 114 ms
92,168 KB
testcase_14 AC 116 ms
94,084 KB
testcase_15 AC 113 ms
92,172 KB
testcase_16 AC 114 ms
93,868 KB
testcase_17 AC 114 ms
92,328 KB
testcase_18 AC 114 ms
92,168 KB
testcase_19 AC 114 ms
92,296 KB
testcase_20 AC 116 ms
92,088 KB
testcase_21 AC 114 ms
92,300 KB
testcase_22 AC 116 ms
93,952 KB
testcase_23 AC 114 ms
93,996 KB
testcase_24 AC 116 ms
92,076 KB
testcase_25 AC 118 ms
93,876 KB
testcase_26 AC 117 ms
94,128 KB
testcase_27 AC 116 ms
92,036 KB
testcase_28 AC 118 ms
94,332 KB
testcase_29 AC 142 ms
91,956 KB
testcase_30 AC 143 ms
94,124 KB
testcase_31 AC 141 ms
96,168 KB
testcase_32 AC 141 ms
94,080 KB
testcase_33 AC 113 ms
89,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;
using System.Collections;
using System.Linq.Expressions;

static class Program
{
    static void Main()
    {
        new Magatro().Solve();
    }
}

struct P
{
    public string Name;
    public int Time;
    public P(string s, int time)
    {
        Name = s;
        Time = time;
    }
}

class Magatro
{
    private int N;
    private int[][] F;
    private int[] M = (new int[1 << 24]).Select(i => -1).ToArray();
    private void Scan()
    {
        N = int.Parse(Console.ReadLine());
        F = new int[N][];
        for (int i = 0; i < N; i++)
        {
            F[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
    }

    public int Sol(int use)
    {
        if (M[use] != -1)
        {
            return M[use];
        }
        int first = -1;
        for (int i = 0; i < N; i++)
        {
            int j = 1 << i;
            if ((use & j) == 0)
            {
                first = i;
                break;
            }
        }
        if (first == -1)
        {
            return 0;
        }
        use += 1 << first;
        int max = -1;
        for (int second = first + 1; second < N; second++)
        {
            int j = 1 << second;
            if ((use & j) == 0)
            {
                use += 1 << second;
                var i = Sol(use) + F[first][second];
                if (max < i)
                {
                    max = i;
                }
                use -= 1 << second;
            }
        }
        use -= 1 << first;
        M[use] = max;
        return max;
    }

    public void Solve()
    {
        Scan();
        Console.WriteLine(Sol(0));
    }

}
0