結果

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

ソースコード

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);
			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);
	}
	static class Int {
		int i,n;
		public Int(int i,int n) {

		}
	}
}
0