結果
問題 | No.133 カードゲーム |
ユーザー |
![]() |
提出日時 | 2019-03-28 11:56:04 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 124 ms / 5,000 ms |
コード長 | 1,416 bytes |
コンパイル時間 | 1,922 ms |
コンパイル使用メモリ | 78,296 KB |
実行使用メモリ | 41,620 KB |
最終ジャッジ日時 | 2024-10-12 16:48:33 |
合計ジャッジ時間 | 5,403 ms |
ジャッジサーバーID (参考情報) |
judge / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
import java.util.ArrayDeque;import java.util.Deque;import java.util.HashSet;import java.util.Scanner;import java.util.Set;public class Main {private static int n;private static int[] a;private static int[] b;private static int win = 0;private static int match = 0;private static void make(Deque<Integer> que) {if(que.size() == n) {match++;int awin = 0;int bwin = 0;for(int i = 0; i < n; i++) {int j = que.poll();if(a[i] > b[j]) awin++;else bwin++;}if(awin > bwin) win++;return;}for(int i = 0; i < n; i++) {if(!que.contains(i)) {Deque<Integer> nque = new ArrayDeque<>();for(int j : que) {nque.add(j);}nque.add(i);make(nque);}}}public static void main(String[] args) {Scanner sc = new Scanner(System.in);n = sc.nextInt();a = new int[n];b = new int[n];for(int i = 0; i < n; i++) {a[i] = sc.nextInt();}for(int i = 0; i < n; i++) {b[i] = sc.nextInt();}make(new ArrayDeque<>());System.out.println(1.0 * win / match);sc.close();}}