結果

問題 No.871 かえるのうた
ユーザー AT274_AT274_
提出日時 2019-10-14 22:10:47
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 543 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 10,728 KB
実行使用メモリ 26,228 KB
最終ジャッジ日時 2023-08-20 09:29:59
合計ジャッジ時間 4,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,792 KB
testcase_01 AC 16 ms
7,860 KB
testcase_02 AC 16 ms
7,740 KB
testcase_03 AC 16 ms
7,872 KB
testcase_04 AC 16 ms
7,736 KB
testcase_05 AC 16 ms
7,824 KB
testcase_06 AC 15 ms
7,824 KB
testcase_07 AC 15 ms
7,772 KB
testcase_08 AC 18 ms
8,492 KB
testcase_09 AC 18 ms
8,788 KB
testcase_10 AC 17 ms
8,308 KB
testcase_11 AC 16 ms
8,412 KB
testcase_12 AC 27 ms
11,012 KB
testcase_13 AC 19 ms
8,732 KB
testcase_14 AC 82 ms
24,156 KB
testcase_15 AC 83 ms
23,952 KB
testcase_16 AC 212 ms
26,228 KB
testcase_17 AC 79 ms
22,552 KB
testcase_18 AC 28 ms
10,784 KB
testcase_19 AC 90 ms
24,252 KB
testcase_20 AC 32 ms
9,508 KB
testcase_21 AC 59 ms
14,808 KB
testcase_22 AC 16 ms
7,772 KB
testcase_23 AC 16 ms
7,884 KB
testcase_24 AC 16 ms
7,804 KB
testcase_25 AC 20 ms
8,388 KB
testcase_26 AC 34 ms
9,368 KB
testcase_27 AC 26 ms
10,540 KB
testcase_28 AC 16 ms
7,728 KB
testcase_29 AC 46 ms
15,116 KB
testcase_30 AC 152 ms
20,044 KB
testcase_31 AC 17 ms
8,468 KB
testcase_32 AC 123 ms
18,356 KB
testcase_33 AC 80 ms
24,004 KB
testcase_34 AC 31 ms
12,288 KB
testcase_35 AC 53 ms
18,000 KB
testcase_36 AC 66 ms
20,844 KB
testcase_37 AC 92 ms
15,096 KB
testcase_38 AC 193 ms
24,020 KB
testcase_39 AC 169 ms
23,280 KB
testcase_40 AC 127 ms
16,500 KB
testcase_41 AC 16 ms
7,736 KB
testcase_42 AC 128 ms
16,412 KB
testcase_43 AC 16 ms
7,736 KB
testcase_44 AC 15 ms
7,768 KB
testcase_45 AC 18 ms
8,344 KB
testcase_46 AC 15 ms
7,920 KB
testcase_47 AC 15 ms
7,776 KB
testcase_48 AC 16 ms
7,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
X = list(map(int, input().split()))
A = list(map(int, input().split()))

l = r = K - 1
ld, rd = X[K - 1] - A[K - 1], X[K - 1] + A[K - 1]


updated = True
while updated:
    updated = False

    while (l - 1 >= 0) and (ld <= X[l - 1]):
        updated = True
        l -= 1
        ld = min(ld, X[l] - A[l])
        rd = max(rd, X[l] + A[l])

    while (r + 1 < N) and (rd >= X[r + 1]):
        updated = True
        r += 1
        ld = min(ld, X[r] - A[r])
        rd = max(rd, X[r] + A[r])

print(r - l + 1)
0