結果
| 問題 | 
                            No.173 カードゲーム(Medium)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             kenkoooo
                         | 
                    
| 提出日時 | 2015-03-27 00:50:53 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,539 bytes | 
| コンパイル時間 | 2,043 ms | 
| コンパイル使用メモリ | 79,700 KB | 
| 実行使用メモリ | 66,136 KB | 
| 最終ジャッジ日時 | 2024-06-29 01:19:44 | 
| 合計ジャッジ時間 | 7,886 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 8 WA * 2 | 
ソースコード
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Random random = new Random();
		int N = sc.nextInt();
		double Pa = sc.nextDouble() * 100;
		double Pb = sc.nextDouble() * 100;
		int[] a = new int[N];
		int[] 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();
		}
		sc.close();
		int rep = 50000;
		int wina = 0;
		for (int i = 0; i < rep; i++) {
			int pointa = 0;
			int pointb = 0;
			ArrayList<Integer> aList = new ArrayList<>();
			ArrayList<Integer> bList = new ArrayList<>();
			for (int j = 0; j < N; j++) {
				aList.add(a[j]);
				bList.add(b[j]);
			}
			Collections.sort(aList);
			Collections.sort(bList);
			for (int j = 0; j < N; j++) {
				int rand_a = random.nextInt(100);
				int rand_b = random.nextInt(100);
				int card_aid = (rand_a < Pa || aList.size() == 1) ? 0 : random.nextInt(aList.size() - 1) + 1;
				int card_bid = (rand_b < Pb || bList.size() == 1) ? 0 : random.nextInt(bList.size() - 1) + 1;
				int card_a = aList.get(card_aid);
				aList.remove(card_aid);
				int card_b = bList.get(card_bid);
				bList.remove(card_bid);
				if (card_a > card_b) {
					pointa += card_a + card_b;
				} else if (card_a < card_b) {
					pointb += card_a + card_b;
				}
			}
			if (pointa > pointb) {
				wina++;
			}
		}
		System.out.println((double) wina / rep);
	}
}
            
            
            
        
            
kenkoooo