結果

問題 No.133 カードゲーム
ユーザー nuwasoginuwasogi
提出日時 2015-11-29 14:31:14
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 2,091 bytes
コンパイル時間 2,601 ms
コンパイル使用メモリ 104,424 KB
実行使用メモリ 25,700 KB
最終ジャッジ日時 2023-09-07 09:23:31
合計ジャッジ時間 5,320 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
23,660 KB
testcase_01 AC 68 ms
23,564 KB
testcase_02 AC 69 ms
23,648 KB
testcase_03 AC 66 ms
23,700 KB
testcase_04 AC 68 ms
23,536 KB
testcase_05 AC 68 ms
23,604 KB
testcase_06 AC 70 ms
25,612 KB
testcase_07 AC 69 ms
25,600 KB
testcase_08 AC 69 ms
23,748 KB
testcase_09 AC 68 ms
23,612 KB
testcase_10 AC 70 ms
25,584 KB
testcase_11 AC 69 ms
23,644 KB
testcase_12 AC 69 ms
23,492 KB
testcase_13 AC 68 ms
23,608 KB
testcase_14 AC 68 ms
25,648 KB
testcase_15 AC 68 ms
25,576 KB
testcase_16 AC 69 ms
25,576 KB
testcase_17 AC 66 ms
21,500 KB
testcase_18 AC 68 ms
23,556 KB
testcase_19 AC 67 ms
21,728 KB
testcase_20 AC 69 ms
25,664 KB
testcase_21 AC 68 ms
23,632 KB
testcase_22 AC 69 ms
25,700 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.Linq;

namespace CardGame_CS
{
    class Program
    {
        static void Main(string[] args)
        {
            Solver sol = new Solver();
            sol.Solve();
        }
    }

    class Solver
    {
        int N;
        int[] A;
        int[] B;
        bool[] used;
        int win = 0;
        int[] AP;

        public void Solve()
        {
            Action<int> CountWin = null;
            CountWin = n =>
            {
                if (n == N)
                {
                    int Lwin = AP.Zip(B, (a, b) => a > b).Count(e=>e);
                    int Llose = N - Lwin;
                    if (Lwin > Llose) win++;
                    return;
                }
                for (int i = 0; i < N; i++)
                {
                    if (!used[i])
                    {
                        AP[n] = A[i];
                        used[i] = true;
                        CountWin(n + 1);
                        used[i] = false;
                    }
                }
            };

            CountWin(0);

            int factN = 1;
            for (int i = 1; i <= N; i++) factN *= i;

            double ans = (double)win / factN;
            Console.WriteLine(ans);
        }

        public Solver()
        {
            N = ri();
            A = ria();
            B = ria();
            AP = new int[N];
            used = new bool[N];
        }

        static String rs() { return Console.ReadLine(); }
        static int ri() { return int.Parse(Console.ReadLine()); }
        static long rl() { return long.Parse(Console.ReadLine()); }
        static double rd() { return double.Parse(Console.ReadLine()); }
        static String[] rsa() { return Console.ReadLine().Split(' '); }
        static int[] ria() { return Console.ReadLine().Split(' ').Select(e => int.Parse(e)).ToArray(); }
        static long[] rla() { return Console.ReadLine().Split(' ').Select(e => long.Parse(e)).ToArray(); }
        static double[] rda() { return Console.ReadLine().Split(' ').Select(e => double.Parse(e)).ToArray(); }
    }
}
0