結果

問題 No.871 かえるのうた
ユーザー tails1434tails1434
提出日時 2020-01-05 19:41:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 156 ms / 2,000 ms
コード長 665 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 86,756 KB
実行使用メモリ 96,060 KB
最終ジャッジ日時 2023-08-20 09:32:23
合計ジャッジ時間 7,696 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
71,240 KB
testcase_01 AC 74 ms
71,264 KB
testcase_02 AC 74 ms
71,380 KB
testcase_03 AC 75 ms
71,556 KB
testcase_04 AC 75 ms
71,240 KB
testcase_05 AC 75 ms
71,268 KB
testcase_06 AC 74 ms
71,320 KB
testcase_07 AC 72 ms
71,256 KB
testcase_08 AC 76 ms
75,712 KB
testcase_09 AC 75 ms
75,776 KB
testcase_10 AC 90 ms
75,616 KB
testcase_11 AC 92 ms
75,700 KB
testcase_12 AC 102 ms
77,900 KB
testcase_13 AC 90 ms
75,788 KB
testcase_14 AC 146 ms
93,764 KB
testcase_15 AC 141 ms
93,728 KB
testcase_16 AC 154 ms
95,144 KB
testcase_17 AC 143 ms
93,608 KB
testcase_18 AC 97 ms
78,464 KB
testcase_19 AC 151 ms
95,104 KB
testcase_20 AC 99 ms
76,356 KB
testcase_21 AC 123 ms
86,220 KB
testcase_22 AC 88 ms
71,352 KB
testcase_23 AC 87 ms
71,316 KB
testcase_24 AC 87 ms
71,352 KB
testcase_25 AC 95 ms
75,984 KB
testcase_26 AC 95 ms
76,116 KB
testcase_27 AC 93 ms
76,244 KB
testcase_28 AC 88 ms
71,308 KB
testcase_29 AC 116 ms
93,200 KB
testcase_30 AC 137 ms
96,060 KB
testcase_31 AC 94 ms
75,976 KB
testcase_32 AC 130 ms
95,856 KB
testcase_33 AC 138 ms
94,516 KB
testcase_34 AC 100 ms
80,260 KB
testcase_35 AC 121 ms
93,116 KB
testcase_36 AC 125 ms
94,692 KB
testcase_37 AC 126 ms
88,192 KB
testcase_38 AC 156 ms
93,352 KB
testcase_39 AC 129 ms
92,348 KB
testcase_40 AC 102 ms
93,364 KB
testcase_41 AC 75 ms
71,124 KB
testcase_42 AC 101 ms
93,108 KB
testcase_43 AC 73 ms
71,316 KB
testcase_44 AC 72 ms
71,316 KB
testcase_45 AC 78 ms
76,044 KB
testcase_46 AC 73 ms
71,312 KB
testcase_47 AC 72 ms
71,312 KB
testcase_48 AC 73 ms
71,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))
    A = list(map(int, input().split()))
    l = r = K - 1
    ld = X[K-1] - A[K-1]
    rd = X[K-1] + A[K-1]

    updated = True
    while updated:
        updated = False

        while l - 1 >= 0 and ld <= X[l - 1]:
            updated = True
            l -= 1
            ld = min(ld, X[l] - A[l])
            rd = max(rd, X[l] + A[l])
        
        while r + 1 < N and rd >= X[r + 1]:
            updated = True
            r += 1
            ld = min(ld, X[r] - A[r])
            rd = max(rd, X[r] + A[r])

    print(r - l + 1)



if __name__ == "__main__":
    main()
0