結果
| 問題 | 
                            No.200 カードファイト!
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ぴろず
                         | 
                    
| 提出日時 | 2015-04-29 01:29:10 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 138 ms / 2,000 ms | 
| コード長 | 1,144 bytes | 
| コンパイル時間 | 4,746 ms | 
| コンパイル使用メモリ | 79,208 KB | 
| 実行使用メモリ | 55,972 KB | 
| 最終ジャッジ日時 | 2024-10-15 08:59:17 | 
| 合計ジャッジ時間 | 7,395 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 26 | 
ソースコード
/* 分からず */
package no200;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int[] b = new int[a];
		for(int i=0;i<a;i++) {
			b[i] = sc.nextInt();
		}
		int c = sc.nextInt();
		int[] d = new int[c];
		for(int i=0;i<c;i++) {
			d[i] = sc.nextInt();
		}
		Arrays.sort(b);
		Arrays.sort(d);
		ArrayList<Integer> handA = new ArrayList<>();
		ArrayList<Integer> handB = new ArrayList<>();
		int ans = 0;
		LOOP: for(int i=0;i<n;i++) {
			if (handA.isEmpty()) {
				for(int j=0;j<a;j++) {
					handA.add(b[j]);
				}
			}
			if (handB.isEmpty()) {
				for(int j=0;j<c;j++) {
					handB.add(d[j]);
				}
			}
			for(int j=handB.size()-1;j>=0;j--) {
				for(int k=0;k<handA.size();k++) {
					if (handA.get(k) > handB.get(j)) {
						handA.remove(k);
						handB.remove(j);
						ans++;
						continue LOOP;
					}
				}
			}
			handA.remove(0);
			handB.remove(handB.size()-1);
//			System.out.println(handA + "," + handB);
		}
		System.out.println(ans);
	}
}
            
            
            
        
            
ぴろず