結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2015-08-10 20:22:10 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 382 ms / 5,000 ms |
コード長 | 1,242 bytes |
コンパイル時間 | 2,797 ms |
コンパイル使用メモリ | 78,704 KB |
実行使用メモリ | 44,312 KB |
最終ジャッジ日時 | 2024-06-25 03:39:29 |
合計ジャッジ時間 | 11,945 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
import java.util.ArrayList;import java.util.Arrays;import java.util.Collections;import java.util.HashSet;import java.util.LinkedList;import java.util.Scanner;import java.util.Set;public class Main {public static void main(String[] args){Scanner sc = new Scanner(System.in);final int N = sc.nextInt();final int[] AS = new int[N];final int[] BS = new int[N];for(int i = 0; i < N; i++){AS[i] = sc.nextInt();}for(int i = 0; i < N; i++){BS[i] = sc.nextInt();}ArrayList<Integer> A_random = new ArrayList<Integer>();ArrayList<Integer> B_random = new ArrayList<Integer>();for(int i = 0; i < N; i++){A_random.add(i);B_random.add(i);}double answer = Double.NaN;for(int i = 0; i < 1000000; i++){Collections.shuffle(A_random);Collections.shuffle(B_random);int count = 0;for(int j = 0; j < N; j++){count += (AS[A_random.get(j)] > BS[B_random.get(j)]) ? 1 : 0;}double prob = (count > N / 2) ? 1 : 0;if(Double.isNaN(answer)){answer = prob;}else{answer += (prob / i);answer *= i;answer /= (i + 1);}//System.out.printf("%d : %.08f\n", i, answer);}System.out.printf("%.08f\n", answer);}}