結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2015-11-29 14:31:14 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 32 ms / 5,000 ms |
コード長 | 2,091 bytes |
コンパイル時間 | 1,234 ms |
コンパイル使用メモリ | 108,288 KB |
実行使用メモリ | 20,096 KB |
最終ジャッジ日時 | 2024-06-25 03:41:29 |
合計ジャッジ時間 | 2,763 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(); }}}