結果

問題 No.871 かえるのうた
ユーザー tktk_snsntktk_snsn
提出日時 2021-02-07 19:37:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 550 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,156 KB
実行使用メモリ 104,152 KB
最終ジャッジ日時 2023-08-20 09:38:25
合計ジャッジ時間 7,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,132 KB
testcase_01 AC 74 ms
71,128 KB
testcase_02 AC 74 ms
71,544 KB
testcase_03 AC 75 ms
71,132 KB
testcase_04 AC 74 ms
71,580 KB
testcase_05 AC 72 ms
71,580 KB
testcase_06 AC 73 ms
71,164 KB
testcase_07 AC 75 ms
71,264 KB
testcase_08 AC 78 ms
75,824 KB
testcase_09 AC 79 ms
75,776 KB
testcase_10 AC 78 ms
75,708 KB
testcase_11 AC 78 ms
75,720 KB
testcase_12 AC 83 ms
79,524 KB
testcase_13 AC 79 ms
75,928 KB
testcase_14 AC 135 ms
102,000 KB
testcase_15 AC 134 ms
102,408 KB
testcase_16 AC 149 ms
104,152 KB
testcase_17 AC 132 ms
98,252 KB
testcase_18 AC 84 ms
80,144 KB
testcase_19 AC 158 ms
103,952 KB
testcase_20 AC 92 ms
76,912 KB
testcase_21 AC 119 ms
90,316 KB
testcase_22 AC 78 ms
71,496 KB
testcase_23 AC 76 ms
71,384 KB
testcase_24 AC 79 ms
71,424 KB
testcase_25 AC 88 ms
76,560 KB
testcase_26 AC 89 ms
76,296 KB
testcase_27 AC 86 ms
76,744 KB
testcase_28 AC 76 ms
71,432 KB
testcase_29 AC 103 ms
97,872 KB
testcase_30 AC 125 ms
96,072 KB
testcase_31 AC 79 ms
75,904 KB
testcase_32 AC 121 ms
96,964 KB
testcase_33 AC 132 ms
98,240 KB
testcase_34 AC 95 ms
82,348 KB
testcase_35 AC 120 ms
98,696 KB
testcase_36 AC 130 ms
96,176 KB
testcase_37 AC 119 ms
92,888 KB
testcase_38 AC 154 ms
99,448 KB
testcase_39 AC 146 ms
97,832 KB
testcase_40 AC 118 ms
98,392 KB
testcase_41 AC 78 ms
71,252 KB
testcase_42 AC 108 ms
98,448 KB
testcase_43 AC 74 ms
71,252 KB
testcase_44 AC 76 ms
71,184 KB
testcase_45 AC 83 ms
76,252 KB
testcase_46 AC 73 ms
71,672 KB
testcase_47 AC 74 ms
71,344 KB
testcase_48 AC 75 ms
71,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
inf = float("inf")
X = [-inf] + list(map(int, input().split())) + [inf]
A = [-1] + list(map(int, input().split())) + [inf]

ans = [0] * (N + 2)

# left
L = X[K]
R = X[K]
i = K
j = K
while i or j < N + 1:
    if i and X[i] >= L:
        ans[i] = 1
        L = min(L, X[i] - A[i])
        R = max(R, X[i] + A[i])
        i -= 1
        continue
    if j < N + 1 and X[j] <= R:
        ans[j] = 1
        L = min(L, X[j] - A[j])
        R = max(R, X[j] + A[j])
        j += 1
        continue
    break


print(sum(ans))
0