結果

問題 No.871 かえるのうた
ユーザー FromBooskaFromBooska
提出日時 2023-04-19 19:47:20
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 922 bytes
コンパイル時間 270 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 98,732 KB
最終ジャッジ日時 2024-04-22 22:18:54
合計ジャッジ時間 5,702 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,096 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 39 ms
52,096 KB
testcase_04 RE -
testcase_05 AC 42 ms
51,584 KB
testcase_06 RE -
testcase_07 AC 40 ms
51,968 KB
testcase_08 AC 44 ms
58,624 KB
testcase_09 AC 52 ms
59,392 KB
testcase_10 RE -
testcase_11 AC 46 ms
58,112 KB
testcase_12 AC 55 ms
67,456 KB
testcase_13 AC 53 ms
59,904 KB
testcase_14 AC 111 ms
93,440 KB
testcase_15 AC 112 ms
93,176 KB
testcase_16 RE -
testcase_17 AC 103 ms
95,188 KB
testcase_18 AC 60 ms
68,096 KB
testcase_19 AC 114 ms
93,976 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 45 ms
51,840 KB
testcase_24 RE -
testcase_25 AC 49 ms
60,544 KB
testcase_26 AC 56 ms
63,872 KB
testcase_27 AC 52 ms
64,640 KB
testcase_28 AC 46 ms
52,096 KB
testcase_29 AC 74 ms
86,912 KB
testcase_30 AC 104 ms
97,792 KB
testcase_31 AC 45 ms
58,880 KB
testcase_32 AC 95 ms
94,464 KB
testcase_33 AC 106 ms
96,384 KB
testcase_34 AC 56 ms
70,144 KB
testcase_35 AC 80 ms
88,448 KB
testcase_36 AC 103 ms
98,732 KB
testcase_37 AC 86 ms
85,076 KB
testcase_38 AC 110 ms
95,304 KB
testcase_39 AC 110 ms
93,552 KB
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 45 ms
51,968 KB
testcase_47 RE -
testcase_48 AC 41 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# K番から右と左に尺取り法
# 毎回min, maxを更新していき、それに合わせて尺取りを動かす

N, K = map(int, input().split())
X = list(map(int, input().split()))
A = list(map(int, input().split()))


K -= 1
left = K
right = K
mn = X[K]-A[K]
mx = X[K]+A[K]
while True:
    improve = False
    
    while left > 1:
        if mn <= X[left-1]:
            left -= 1
            improve = True
            mn = min(mn, X[left]-A[left])
            mx = max(mx, X[left]+A[left])
        else:
            break            
        
    while right < N:
        if mx >= X[right+1]:
            right += 1
            improve = True
            mn = min(mn, X[right]-A[right])
            mx = max(mx, X[right]+A[right])
        else:
            break             
    #print('improve', improve, 'left', left, 'right', right)
    if improve == False:
        break
    
ans = right+1-left
print(ans)
0