結果

問題 No.949 飲酒プログラミングコンテスト
ユーザー tentententen
提出日時 2020-12-16 19:20:38
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,339 bytes
コンパイル時間 2,464 ms
コンパイル使用メモリ 77,172 KB
実行使用メモリ 60,756 KB
最終ジャッジ日時 2023-10-20 09:47:53
合計ジャッジ時間 11,247 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
57,372 KB
testcase_01 AC 135 ms
57,228 KB
testcase_02 AC 135 ms
57,492 KB
testcase_03 AC 138 ms
57,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 160 ms
57,716 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 183 ms
57,684 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 215 ms
43,616 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 217 ms
43,960 KB
testcase_18 AC 257 ms
46,660 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 195 ms
42,408 KB
testcase_24 AC 249 ms
45,612 KB
testcase_25 WA -
testcase_26 AC 268 ms
46,552 KB
testcase_27 WA -
testcase_28 AC 267 ms
46,708 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 270 ms
46,308 KB
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] kenArr = new int[n + 1];
		for (int i = 0; i <= n; i++) {
		    kenArr[i] = sc.nextInt();
		}
		int[] kooArr = new int[n + 1];
		for (int i = 0; i <= n; i++) {
		    kooArr[i] = sc.nextInt();
		}
		int[] strategy = new int[n];
		int kenIdx = 0;
		int kooIdx = 0;
		for (int i = 0; i < n; i++) {
		    if (kenArr[kenIdx + 1] + kooArr[kooIdx] >= kenArr[kenIdx] + kooArr[kooIdx + 1]) {
		        strategy[i] = kenArr[kenIdx + 1] + kooArr[kooIdx];
		        kenIdx++;
		    } else {
		        strategy[i] = kenArr[kenIdx] + kooArr[kooIdx + 1];
		        kooIdx++;
		    }
		}
		int[] questions = new int[n];
		for (int i = 0; i < n; i++) {
		    questions[i] = sc.nextInt();
		}
		Arrays.sort(questions);
		if (questions[0] > strategy[0]) {
		    System.out.println(0);
		    return;
		}
		int left = 0;
		int right = n + 1;
		while (right - left > 1) {
		    int m = (left + right) / 2;
		    boolean can = true;
		    for (int i = 0; i < m; i++) {
		        if (questions[m - i - 1] > strategy[i]) {
		            can = false;
		            break;
		        }
		    }
		    if (can) {
		        left = m;
		    } else {
		        right = m;
		    }
		}
		System.out.println(left);
	}
}
0