結果

問題 No.133 カードゲーム
ユーザー ika3ika3
提出日時 2019-02-25 15:54:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 957 bytes
コンパイル時間 3,401 ms
コンパイル使用メモリ 79,352 KB
実行使用メモリ 56,552 KB
最終ジャッジ日時 2023-08-27 00:49:01
合計ジャッジ時間 6,220 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
56,116 KB
testcase_01 AC 122 ms
56,152 KB
testcase_02 AC 121 ms
56,452 KB
testcase_03 AC 120 ms
56,228 KB
testcase_04 AC 120 ms
55,660 KB
testcase_05 AC 120 ms
56,024 KB
testcase_06 AC 121 ms
55,864 KB
testcase_07 AC 121 ms
56,036 KB
testcase_08 AC 122 ms
55,764 KB
testcase_09 AC 123 ms
55,692 KB
testcase_10 AC 123 ms
56,080 KB
testcase_11 AC 121 ms
56,164 KB
testcase_12 AC 121 ms
55,652 KB
testcase_13 AC 122 ms
55,732 KB
testcase_14 AC 122 ms
56,108 KB
testcase_15 AC 122 ms
55,916 KB
testcase_16 AC 119 ms
55,780 KB
testcase_17 AC 120 ms
55,500 KB
testcase_18 AC 119 ms
55,972 KB
testcase_19 AC 120 ms
55,984 KB
testcase_20 AC 122 ms
56,180 KB
testcase_21 AC 120 ms
55,872 KB
testcase_22 AC 120 ms
56,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	static int[] a1;
	static int[] b1;
	static double sum1;
	static boolean[] a2;
	static int n;
	static int[] a3;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		sum1=0;
		a1=new int[n];
		b1=new int[n];
		a2=new boolean[n];
		a3=new int[n];
		double sum=1;
		for(int i = 0; i<n; i++){
			int a = sc.nextInt();
			a1[i]=a;
		}
		for(int i = 0; i<n; i++){
			int b = sc.nextInt();
			b1[i]=b;
		}
		for(int i=2; i<=n; i++){
			sum*=i;
		}
		dfs(n-1);
		System.out.println(sum1/sum);
	}
	static void dfs(int k){
		for(int i=0; i<n; i++){
			if(!a2[i]){
				a3[k]=a1[i];
				a2[i]=true;
				dfs(k-1);
				a2[i]=false;
			}
		}
		if(k==0){
			if(judge(a3)){
				sum1++;
			}
		}
	} 
	
	static boolean judge(int[] c){
		int win=0;
		for(int i = 0; i<n; i++){
			if(c[i]>b1[i]){
				win++;
			}
		}
		if(win>(n/2)){
			return true;
		}else{
			return false;
		}
	}
}
0