結果

問題 No.2389 Cheating Code Golf
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-21 23:17:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 1,913 bytes
コンパイル時間 4,247 ms
コンパイル使用メモリ 111,980 KB
実行使用メモリ 26,452 KB
最終ジャッジ日時 2023-10-21 23:17:29
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
26,452 KB
testcase_01 AC 30 ms
26,452 KB
testcase_02 AC 37 ms
26,440 KB
testcase_03 AC 81 ms
26,440 KB
testcase_04 AC 81 ms
26,440 KB
testcase_05 AC 31 ms
26,452 KB
testcase_06 AC 29 ms
26,452 KB
testcase_07 AC 33 ms
26,440 KB
testcase_08 AC 45 ms
26,440 KB
testcase_09 AC 31 ms
26,452 KB
testcase_10 AC 29 ms
26,452 KB
testcase_11 AC 30 ms
26,452 KB
testcase_12 AC 28 ms
26,452 KB
testcase_13 AC 38 ms
26,440 KB
testcase_14 AC 31 ms
26,452 KB
testcase_15 AC 31 ms
26,452 KB
testcase_16 AC 39 ms
26,440 KB
testcase_17 AC 30 ms
26,452 KB
testcase_18 AC 32 ms
26,452 KB
testcase_19 AC 31 ms
26,452 KB
testcase_20 AC 31 ms
26,452 KB
testcase_21 AC 30 ms
26,452 KB
testcase_22 AC 28 ms
26,452 KB
testcase_23 AC 28 ms
26,452 KB
testcase_24 AC 32 ms
26,452 KB
testcase_25 AC 32 ms
26,452 KB
testcase_26 AC 32 ms
26,452 KB
testcase_27 AC 32 ms
26,440 KB
testcase_28 AC 31 ms
26,452 KB
testcase_29 AC 30 ms
26,452 KB
testcase_30 AC 38 ms
26,440 KB
testcase_31 AC 30 ms
26,452 KB
testcase_32 AC 29 ms
26,452 KB
testcase_33 AC 29 ms
26,452 KB
testcase_34 AC 34 ms
26,440 KB
testcase_35 AC 30 ms
26,452 KB
testcase_36 AC 36 ms
26,440 KB
testcase_37 AC 29 ms
26,452 KB
testcase_38 AC 48 ms
26,440 KB
testcase_39 AC 32 ms
26,452 KB
testcase_40 AC 31 ms
26,452 KB
testcase_41 AC 33 ms
26,440 KB
testcase_42 AC 30 ms
26,452 KB
testcase_43 AC 28 ms
26,452 KB
testcase_44 AC 30 ms
26,452 KB
testcase_45 AC 46 ms
26,440 KB
testcase_46 AC 37 ms
26,440 KB
testcase_47 AC 32 ms
26,452 KB
testcase_48 AC 30 ms
26,452 KB
testcase_49 AC 33 ms
26,452 KB
testcase_50 AC 30 ms
26,452 KB
testcase_51 AC 32 ms
26,452 KB
testcase_52 AC 29 ms
26,452 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 static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var map = NArr(n);
        var bitmax = 1 << n;
        var dp = new double[bitmax][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = Enumerable.Repeat(double.MinValue, m + 1).ToArray();
        dp[0][0] = 0;
        var visited = new bool[bitmax][];
        for (var i = 0; i < visited.Length; ++i) visited[i] = new bool[m + 1];
        DFS(n, bitmax, 0, 0, map, dp, visited);
        WriteLine(dp[0][0]);
    }
    static void DFS(int n, int bitmax, int b, int mi, int[][] map, double[][] dp, bool[][] visited)
    {
        if (visited[b][mi]) return;
        var max = 0.0;
        for (var i = 0; i < n; ++i)
        {
            if ((b & (1 << i)) != 0) continue;
            var nb = b | (1 << i);
            DFS(n, bitmax, nb, mi, map, dp, visited);
            max = Math.Max(max, dp[nb][mi] + 1.0 / map[i][0]);
            if (mi + 1 < dp[i].Length)
            {
                DFS(n, bitmax, b, mi + 1, map, dp, visited);
                max = Math.Max(max,
                    (1.0 / map[i][2]) * (dp[nb][mi] + 1.0 / map[i][1]) + (1.0 - 1.0 / map[i][2]) * dp[b][mi + 1]);
            }
        }
        visited[b][mi] = true;
        dp[b][mi] = max;
    }
    static void DebugTable<T>(T[][] table)
    {
        Console.WriteLine("{");
        foreach (var list in table) Console.WriteLine(string.Join(", ", list));
        Console.WriteLine("}");
    }
}
0