結果

問題 No.871 かえるのうた
ユーザー kit84kit84
提出日時 2019-08-30 22:51:14
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 127 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,908 KB
最終ジャッジ日時 2024-05-01 19:41:35
合計ジャッジ時間 4,972 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,752 KB
testcase_01 AC 29 ms
10,880 KB
testcase_02 AC 26 ms
10,880 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 26 ms
10,752 KB
testcase_05 AC 25 ms
10,752 KB
testcase_06 WA -
testcase_07 AC 25 ms
10,752 KB
testcase_08 AC 28 ms
11,136 KB
testcase_09 AC 29 ms
11,136 KB
testcase_10 AC 26 ms
10,752 KB
testcase_11 AC 26 ms
10,880 KB
testcase_12 AC 39 ms
13,524 KB
testcase_13 AC 29 ms
11,392 KB
testcase_14 AC 103 ms
27,964 KB
testcase_15 AC 98 ms
27,988 KB
testcase_16 AC 287 ms
28,908 KB
testcase_17 AC 100 ms
26,348 KB
testcase_18 AC 38 ms
13,132 KB
testcase_19 WA -
testcase_20 AC 47 ms
11,984 KB
testcase_21 AC 78 ms
16,316 KB
testcase_22 AC 26 ms
10,752 KB
testcase_23 AC 26 ms
10,752 KB
testcase_24 AC 26 ms
10,880 KB
testcase_25 AC 31 ms
11,136 KB
testcase_26 AC 48 ms
12,032 KB
testcase_27 AC 34 ms
12,800 KB
testcase_28 AC 25 ms
10,752 KB
testcase_29 AC 59 ms
17,756 KB
testcase_30 AC 213 ms
22,792 KB
testcase_31 AC 29 ms
11,008 KB
testcase_32 AC 179 ms
20,196 KB
testcase_33 WA -
testcase_34 AC 46 ms
14,892 KB
testcase_35 AC 72 ms
19,388 KB
testcase_36 AC 85 ms
22,480 KB
testcase_37 AC 139 ms
17,336 KB
testcase_38 AC 265 ms
25,656 KB
testcase_39 WA -
testcase_40 AC 172 ms
17,864 KB
testcase_41 AC 26 ms
10,752 KB
testcase_42 AC 174 ms
17,992 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 28 ms
10,752 KB
testcase_46 AC 24 ms
10,880 KB
testcase_47 AC 25 ms
10,880 KB
testcase_48 AC 24 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# #debug
def dprint(*ar):
    # print(*ar)
    pass


N, K = map(int, input().split())
vX = list(map(int, input().split()))
vA = list(map(int, input().split()))

# init
# 0-origin
initX = vX[K-1]
initA = vA[K-1]
L, R = (initX-initA), (initX+initA)

# for plus
prevX, prevA = initX, initA
for i in range(K, N):
    dist = abs(vX[i] - prevX)
    dprint(dist, i, L, R)
    if dist > prevA:
        break
    else:
        prevX = vX[i]
        prevA = max(vA[i], prevA - dist)
        R = max(R, prevX + prevA)
        L = min(L, prevX - prevA)

# for minus
prevX, prevA = initX, initA
for i in range(K-2, -1, -1):
    dist = abs(vX[i] - prevX)
    dprint(dist, i, L, R)
    if dist > prevA:
        break
    else:
        prevX = vX[i]
        prevA = max(vA[i], prevA - dist)
        R = max(R, prevX + prevA)
        L = min(L, prevX - prevA)

res = sum([L<=x<=R for x in vX])
print(res)
0