結果

問題 No.200 カードファイト!
ユーザー ぴろず
提出日時 2015-04-29 00:47:57
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,139 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 79,552 KB
実行使用メモリ 41,408 KB
最終ジャッジ日時 2024-07-05 15:49:37
合計ジャッジ時間 5,765 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

/* 分からず */

package no200;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
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;
		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]);
				}
			}
			int low = handB.get(0);
			int ceilI = Collections.binarySearch(handA, low+1);
			if (ceilI < 0) {
				ceilI = ~ceilI;
			}
			if (ceilI >= handA.size()) {
				handA.remove(0);
				handB.remove(handB.size()-1);
			}else{
				handA.remove(ceilI);
				handB.remove(0);
				ans++;
			}
		}
		System.out.println(ans);
	}
}
0