結果

問題 No.871 かえるのうた
ユーザー takakintakakin
提出日時 2020-06-25 23:29:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 28,120 KB
最終ジャッジ日時 2024-05-07 16:39:20
合計ジャッジ時間 5,309 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,752 KB
testcase_01 AC 34 ms
10,880 KB
testcase_02 AC 28 ms
10,880 KB
testcase_03 AC 26 ms
10,752 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 28 ms
10,880 KB
testcase_08 AC 30 ms
11,136 KB
testcase_09 AC 33 ms
11,264 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 28 ms
10,880 KB
testcase_12 AC 42 ms
13,568 KB
testcase_13 AC 35 ms
11,392 KB
testcase_14 AC 112 ms
28,004 KB
testcase_15 AC 113 ms
28,084 KB
testcase_16 AC 256 ms
25,920 KB
testcase_17 AC 110 ms
26,500 KB
testcase_18 AC 40 ms
13,296 KB
testcase_19 AC 118 ms
28,120 KB
testcase_20 AC 45 ms
12,072 KB
testcase_21 AC 80 ms
16,260 KB
testcase_22 AC 28 ms
10,880 KB
testcase_23 AC 27 ms
10,752 KB
testcase_24 AC 27 ms
10,752 KB
testcase_25 AC 31 ms
11,008 KB
testcase_26 AC 48 ms
12,032 KB
testcase_27 AC 40 ms
13,056 KB
testcase_28 AC 27 ms
10,752 KB
testcase_29 AC 68 ms
17,924 KB
testcase_30 AC 184 ms
22,964 KB
testcase_31 AC 30 ms
11,136 KB
testcase_32 AC 155 ms
21,280 KB
testcase_33 AC 107 ms
26,744 KB
testcase_34 AC 48 ms
15,236 KB
testcase_35 AC 74 ms
19,348 KB
testcase_36 AC 92 ms
22,328 KB
testcase_37 AC 119 ms
17,296 KB
testcase_38 AC 239 ms
27,084 KB
testcase_39 AC 215 ms
26,004 KB
testcase_40 AC 164 ms
17,828 KB
testcase_41 AC 27 ms
10,880 KB
testcase_42 AC 169 ms
17,832 KB
testcase_43 AC 28 ms
10,752 KB
testcase_44 AC 29 ms
10,752 KB
testcase_45 AC 32 ms
10,880 KB
testcase_46 AC 28 ms
10,752 KB
testcase_47 AC 27 ms
10,880 KB
testcase_48 AC 27 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,k=map(int,input().split())
X=[int(i) for i in input().split()]
A=[int(i) for i in input().split()]
l,r=X[k-1]-A[k-1],X[k-1]+A[k-1]
ll,rr=k-1,k-1
while True:
  if ll-1>=0 and X[ll-1]>=l:
    l=min(l,X[ll-1]-A[ll-1])
    r=max(r,X[ll-1]+A[ll-1])
    ll-=1
  elif rr+1<n and X[rr+1]<=r:
    r=max(r,X[rr+1]+A[rr+1])
    l=min(l,X[rr+1]-A[rr+1])
    rr+=1 
  else:
    break
print(rr-ll+1)

0