結果

問題 No.871 かえるのうた
ユーザー URechaRechaURechaRecha
提出日時 2019-09-02 16:30:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 821 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 40,372 KB
最終ジャッジ日時 2023-08-20 09:28:18
合計ジャッジ時間 7,441 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,244 KB
testcase_01 AC 16 ms
8,188 KB
testcase_02 AC 16 ms
8,112 KB
testcase_03 AC 17 ms
7,728 KB
testcase_04 AC 16 ms
8,204 KB
testcase_05 AC 16 ms
8,124 KB
testcase_06 AC 16 ms
8,160 KB
testcase_07 AC 16 ms
8,256 KB
testcase_08 AC 21 ms
8,884 KB
testcase_09 AC 21 ms
9,336 KB
testcase_10 AC 17 ms
8,228 KB
testcase_11 AC 17 ms
8,608 KB
testcase_12 AC 41 ms
13,596 KB
testcase_13 AC 23 ms
9,512 KB
testcase_14 AC 145 ms
38,468 KB
testcase_15 AC 143 ms
38,492 KB
testcase_16 AC 664 ms
40,372 KB
testcase_17 AC 134 ms
36,496 KB
testcase_18 AC 38 ms
12,312 KB
testcase_19 AC 157 ms
40,116 KB
testcase_20 AC 39 ms
10,612 KB
testcase_21 AC 86 ms
19,416 KB
testcase_22 AC 16 ms
8,284 KB
testcase_23 AC 17 ms
8,144 KB
testcase_24 AC 15 ms
7,768 KB
testcase_25 AC 22 ms
8,744 KB
testcase_26 AC 46 ms
10,972 KB
testcase_27 AC 35 ms
12,372 KB
testcase_28 AC 16 ms
8,208 KB
testcase_29 AC 78 ms
20,288 KB
testcase_30 AC 239 ms
28,832 KB
testcase_31 AC 19 ms
8,940 KB
testcase_32 AC 232 ms
27,764 KB
testcase_33 AC 161 ms
36,092 KB
testcase_34 AC 47 ms
16,196 KB
testcase_35 AC 86 ms
25,252 KB
testcase_36 AC 112 ms
31,884 KB
testcase_37 AC 141 ms
20,300 KB
testcase_38 AC 631 ms
35,256 KB
testcase_39 AC 393 ms
35,352 KB
testcase_40 AC 214 ms
21,168 KB
testcase_41 AC 17 ms
8,160 KB
testcase_42 AC 534 ms
21,180 KB
testcase_43 AC 16 ms
8,188 KB
testcase_44 AC 16 ms
8,204 KB
testcase_45 AC 21 ms
8,484 KB
testcase_46 AC 16 ms
8,332 KB
testcase_47 AC 16 ms
8,248 KB
testcase_48 AC 16 ms
8,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
frogs = []
cnt = 1
for p,v in zip(input().split(),input().split()):
    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]
            if frogs_before_K[-1][0]+frogs_before_K[-1][1] > section[1]:
                section[1] = 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[0]:
                section[0] = frogs_after_K[0][0]-frogs_after_K[0][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