結果

問題 No.871 かえるのうた
ユーザー htensaihtensai
提出日時 2019-11-11 13:47:57
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,238 bytes
コンパイル時間 2,466 ms
コンパイル使用メモリ 73,920 KB
実行使用メモリ 67,504 KB
最終ジャッジ日時 2023-10-13 08:00:43
合計ジャッジ時間 24,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 119 ms
55,804 KB
testcase_01 WA -
testcase_02 AC 122 ms
54,488 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 879 ms
67,136 KB
testcase_18 AC 425 ms
60,568 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 129 ms
56,284 KB
testcase_29 AC 627 ms
60,896 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 492 ms
61,104 KB
testcase_35 WA -
testcase_36 AC 806 ms
63,908 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 126 ms
55,836 KB
testcase_42 AC 544 ms
60,980 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 122 ms
56,180 KB
testcase_47 AC 119 ms
55,780 KB
testcase_48 AC 124 ms
55,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt() - 1;
		long[] xArr = new long[n + 2];
		for (int i = 1; i <= n; i++) {
		    xArr[i] = sc.nextLong();
		}
		xArr[0] = Long.MIN_VALUE;
		xArr[n + 1] = Long.MAX_VALUE;
		long[] aArr = new long[n + 1];
		for (int i = 1; i <= n; i++) {
		    aArr[i] = sc.nextLong();
		}
		int min = Integer.MAX_VALUE;
		int target = k;
		while (min != target) {
		    min = target;
		    int left = 0;
		    int right = target;
		    while (right - left > 1) {
		        int m = (left + right) / 2;
		        if (xArr[target] - xArr[m] <= aArr[target]) {
		            right = m;
		        } else {
		            left = m;
		        }
		    }
		    target = right;
		}
		int max = Integer.MIN_VALUE;
		target = k;
		while (max != target) {
		    max = target;
		    int left = target;
		    int right = n;
		    while (right - left > 1) {
		        int m = (left + right) / 2;
		        if (xArr[m] - xArr[target] <= aArr[target]) {
		            left = m;
		        } else {
		            right = m;
		        }
		    }
		    target = left;
		}
		System.out.println(max - min + 1);
	}
}
0