結果

問題 No.871 かえるのうた
ユーザー htensaihtensai
提出日時 2019-12-09 22:40:55
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 929 bytes
コンパイル時間 2,801 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 68,896 KB
最終ジャッジ日時 2023-09-05 11:46:59
合計ジャッジ時間 26,615 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,448 KB
testcase_01 WA -
testcase_02 AC 124 ms
56,180 KB
testcase_03 AC 139 ms
56,012 KB
testcase_04 AC 133 ms
55,444 KB
testcase_05 AC 134 ms
55,772 KB
testcase_06 WA -
testcase_07 AC 139 ms
56,088 KB
testcase_08 AC 226 ms
58,820 KB
testcase_09 AC 227 ms
59,236 KB
testcase_10 AC 188 ms
59,176 KB
testcase_11 AC 204 ms
58,376 KB
testcase_12 AC 428 ms
60,620 KB
testcase_13 AC 253 ms
59,068 KB
testcase_14 AC 978 ms
68,896 KB
testcase_15 AC 916 ms
67,044 KB
testcase_16 AC 947 ms
67,636 KB
testcase_17 AC 872 ms
66,980 KB
testcase_18 AC 453 ms
60,768 KB
testcase_19 WA -
testcase_20 AC 360 ms
60,436 KB
testcase_21 AC 621 ms
60,896 KB
testcase_22 AC 133 ms
56,392 KB
testcase_23 AC 140 ms
55,984 KB
testcase_24 AC 125 ms
56,028 KB
testcase_25 AC 211 ms
58,888 KB
testcase_26 AC 303 ms
60,248 KB
testcase_27 AC 356 ms
60,420 KB
testcase_28 AC 132 ms
55,792 KB
testcase_29 AC 643 ms
61,108 KB
testcase_30 AC 732 ms
61,680 KB
testcase_31 AC 228 ms
59,320 KB
testcase_32 AC 699 ms
61,232 KB
testcase_33 WA -
testcase_34 AC 493 ms
61,184 KB
testcase_35 AC 681 ms
61,744 KB
testcase_36 AC 817 ms
63,924 KB
testcase_37 AC 632 ms
60,884 KB
testcase_38 AC 914 ms
67,112 KB
testcase_39 WA -
testcase_40 AC 566 ms
60,272 KB
testcase_41 AC 125 ms
55,580 KB
testcase_42 AC 558 ms
60,856 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 126 ms
57,804 KB
testcase_47 AC 125 ms
55,896 KB
testcase_48 AC 126 ms
55,636 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[] idxes = new long[n];
        for (int i = 0; i < n; i++) {
            idxes[i] = sc.nextLong();
        }
        long[] values = new long[n];
        for (int i = 0; i < n; i++) {
            values[i] = sc.nextLong();
        }
        long left = idxes[k] - values[k];
        long right = idxes[k] + values[k];
        int plus = k;
        while (plus < n - 1 && idxes[plus + 1] <= right) {
            plus++;
            right = Math.max(right, idxes[plus] + values[plus]);
        }
        int minus = k;
        while(minus > 0 && idxes[minus - 1] >= left) {
            minus--;
            left = Math.min(left, idxes[minus] - values[minus]);
        }
        System.out.println(plus - minus + 1);
    }
}
0