結果

問題 No.871 かえるのうた
ユーザー mkawa2mkawa2
提出日時 2021-03-17 12:28:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 1,074 bytes
コンパイル時間 897 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 24,628 KB
最終ジャッジ日時 2023-08-20 09:38:46
合計ジャッジ時間 4,847 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,216 KB
testcase_01 AC 17 ms
8,376 KB
testcase_02 AC 17 ms
8,256 KB
testcase_03 AC 17 ms
8,380 KB
testcase_04 AC 17 ms
8,296 KB
testcase_05 AC 16 ms
8,308 KB
testcase_06 AC 17 ms
8,208 KB
testcase_07 AC 17 ms
8,248 KB
testcase_08 AC 18 ms
8,580 KB
testcase_09 AC 20 ms
8,460 KB
testcase_10 AC 18 ms
8,072 KB
testcase_11 AC 17 ms
8,080 KB
testcase_12 AC 28 ms
10,760 KB
testcase_13 AC 19 ms
8,980 KB
testcase_14 AC 83 ms
22,592 KB
testcase_15 AC 80 ms
22,544 KB
testcase_16 AC 208 ms
24,628 KB
testcase_17 AC 75 ms
21,352 KB
testcase_18 AC 28 ms
10,568 KB
testcase_19 AC 87 ms
22,916 KB
testcase_20 AC 33 ms
9,500 KB
testcase_21 AC 60 ms
13,552 KB
testcase_22 AC 18 ms
8,248 KB
testcase_23 AC 17 ms
8,252 KB
testcase_24 AC 17 ms
8,268 KB
testcase_25 AC 20 ms
8,508 KB
testcase_26 AC 35 ms
9,576 KB
testcase_27 AC 25 ms
10,524 KB
testcase_28 AC 16 ms
8,304 KB
testcase_29 AC 46 ms
14,332 KB
testcase_30 AC 147 ms
18,380 KB
testcase_31 AC 18 ms
8,628 KB
testcase_32 AC 119 ms
17,480 KB
testcase_33 AC 77 ms
21,676 KB
testcase_34 AC 31 ms
11,980 KB
testcase_35 AC 52 ms
16,504 KB
testcase_36 AC 65 ms
19,628 KB
testcase_37 AC 92 ms
14,132 KB
testcase_38 AC 188 ms
21,616 KB
testcase_39 AC 169 ms
20,792 KB
testcase_40 AC 128 ms
14,512 KB
testcase_41 AC 17 ms
8,312 KB
testcase_42 AC 125 ms
14,464 KB
testcase_43 AC 17 ms
8,228 KB
testcase_44 AC 17 ms
8,400 KB
testcase_45 AC 20 ms
8,012 KB
testcase_46 AC 16 ms
8,232 KB
testcase_47 AC 17 ms
8,224 KB
testcase_48 AC 16 ms
8,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
def BI(): return sys.stdin.buffer.readline().rstrip()
def SI(): return sys.stdin.buffer.readline().rstrip().decode()
# dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]
dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
inf = 10**16
md = 998244353
# md = 10**9+7

n,k=LI()
xx=LI()
aa=LI()

k-=1
i=j=k

l=xx[k]-aa[k]
r=xx[k]+aa[k]
update=True
while update:
    update=False
    while i-1>=0 and xx[i-1]>=l:
        i-=1
        l=min(l,xx[i]-aa[i])
        r=max(r,xx[i]+aa[i])
        update=True
    while j+1<n and xx[j+1]<=r:
        j+=1
        l=min(l,xx[j]-aa[j])
        r=max(r,xx[j]+aa[j])
        update=True

print(j-i+1)
0