結果

問題 No.871 かえるのうた
ユーザー URechaRecha
提出日時 2019-09-02 16:24:21
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,044 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 39,904 KB
最終ジャッジ日時 2024-12-16 01:13:40
合計ジャッジ時間 8,114 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 41 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
frogs = []
cnt = 1
for p,v in zip(input().split(),input().split()):#zip(frogs_p,frogs_v):
    frogs.append((int(p),int(v)))
#K番目が鳴いた時、声が響く区間
section = [frogs[K-1][0] - frogs[K-1][1], frogs[K-1][0] + frogs[K-1][1]]
#K番目の蛙の前後の集団
frogs_before_K = frogs[:K-1]
frogs_after_K = frogs[K:]

flg = True
while flg:
    flg = False
    if len(frogs_before_K) > 0:
        if frogs_before_K[-1][0] in range(section[0],section[1]+1):
            cnt +=1
            if frogs_before_K[-1][0]-frogs_before_K[-1][1] < section[0]:
                section[0] = frogs_before_K[-1][0]-frogs_before_K[-1][1]
            frogs_before_K.pop(-1)
            flg = True
    if len(frogs_after_K) >0:
        if frogs_after_K[0][0] in range(section[0],section[1]+1):
            cnt +=1
            if frogs_after_K[0][0]+frogs_after_K[0][1] > section[1]:
                section[1] = frogs_after_K[0][0]+frogs_after_K[0][1]
            frogs_after_K.pop(0)
            flg = True
print(cnt)
0