結果

問題 No.871 かえるのうた
ユーザー shinichishinichi
提出日時 2021-09-22 17:19:17
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 133 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 87,164 KB
実行使用メモリ 95,960 KB
最終ジャッジ日時 2023-08-20 09:40:16
合計ジャッジ時間 6,873 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,264 KB
testcase_01 AC 71 ms
71,308 KB
testcase_02 AC 74 ms
71,312 KB
testcase_03 AC 74 ms
70,956 KB
testcase_04 AC 72 ms
71,412 KB
testcase_05 AC 72 ms
71,272 KB
testcase_06 AC 71 ms
71,348 KB
testcase_07 AC 74 ms
71,456 KB
testcase_08 AC 75 ms
75,500 KB
testcase_09 AC 75 ms
75,548 KB
testcase_10 AC 76 ms
75,624 KB
testcase_11 AC 75 ms
75,624 KB
testcase_12 AC 82 ms
77,788 KB
testcase_13 AC 77 ms
75,520 KB
testcase_14 AC 122 ms
93,688 KB
testcase_15 AC 122 ms
93,560 KB
testcase_16 AC 133 ms
95,628 KB
testcase_17 AC 120 ms
93,364 KB
testcase_18 AC 81 ms
78,260 KB
testcase_19 AC 130 ms
95,068 KB
testcase_20 AC 84 ms
76,552 KB
testcase_21 AC 105 ms
86,384 KB
testcase_22 AC 73 ms
71,420 KB
testcase_23 AC 71 ms
70,972 KB
testcase_24 AC 72 ms
71,324 KB
testcase_25 AC 80 ms
76,396 KB
testcase_26 AC 80 ms
76,500 KB
testcase_27 AC 79 ms
76,156 KB
testcase_28 AC 72 ms
71,300 KB
testcase_29 AC 96 ms
93,064 KB
testcase_30 AC 114 ms
95,960 KB
testcase_31 AC 77 ms
75,628 KB
testcase_32 AC 116 ms
95,148 KB
testcase_33 AC 120 ms
94,476 KB
testcase_34 AC 84 ms
80,084 KB
testcase_35 AC 101 ms
92,732 KB
testcase_36 AC 111 ms
94,736 KB
testcase_37 AC 103 ms
88,084 KB
testcase_38 AC 128 ms
93,568 KB
testcase_39 AC 126 ms
92,508 KB
testcase_40 AC 103 ms
93,604 KB
testcase_41 AC 72 ms
71,228 KB
testcase_42 AC 101 ms
93,368 KB
testcase_43 AC 74 ms
71,416 KB
testcase_44 AC 74 ms
71,124 KB
testcase_45 AC 80 ms
76,176 KB
testcase_46 AC 79 ms
71,124 KB
testcase_47 AC 72 ms
71,076 KB
testcase_48 AC 71 ms
71,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

left, right = K, K
left_range, right_range = X[K] - A[K], X[K] + A[K]
while True:
    update = False
    while left != 0 and X[left-1] >= left_range:
        left -= 1
        left_range = min(left_range, X[left] - A[left])
        right_range = max(right_range, X[left]+A[left])
        update = True
    while right != N-1 and X[right+1] <= right_range:
        right += 1
        left_range = min(left_range, X[right] - A[right])
        right_range = max(right_range, X[right] + A[right])
        update = True
    if not update:
        break
print(right - left + 1)

0