結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
51,968 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 AC 39 ms
52,224 KB
testcase_04 RE -
testcase_05 AC 40 ms
51,584 KB
testcase_06 RE -
testcase_07 AC 41 ms
51,968 KB
testcase_08 AC 45 ms
59,264 KB
testcase_09 AC 46 ms
59,136 KB
testcase_10 RE -
testcase_11 AC 46 ms
58,368 KB
testcase_12 AC 53 ms
67,456 KB
testcase_13 AC 46 ms
60,288 KB
testcase_14 AC 106 ms
93,248 KB
testcase_15 AC 99 ms
93,284 KB
testcase_16 RE -
testcase_17 AC 98 ms
94,932 KB
testcase_18 AC 55 ms
68,224 KB
testcase_19 AC 111 ms
93,644 KB
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 42 ms
51,840 KB
testcase_24 RE -
testcase_25 AC 49 ms
60,416 KB
testcase_26 AC 51 ms
63,872 KB
testcase_27 AC 50 ms
64,768 KB
testcase_28 AC 40 ms
52,352 KB
testcase_29 AC 72 ms
86,784 KB
testcase_30 AC 99 ms
97,536 KB
testcase_31 AC 44 ms
59,004 KB
testcase_32 AC 94 ms
94,720 KB
testcase_33 AC 98 ms
96,232 KB
testcase_34 AC 56 ms
70,404 KB
testcase_35 AC 77 ms
88,192 KB
testcase_36 AC 93 ms
98,816 KB
testcase_37 AC 78 ms
84,804 KB
testcase_38 AC 108 ms
94,976 KB
testcase_39 AC 101 ms
93,324 KB
testcase_40 RE -
testcase_41 AC 39 ms
52,472 KB
testcase_42 WA -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 AC 40 ms
52,096 KB
testcase_47 AC 40 ms
52,352 KB
testcase_48 AC 40 ms
52,096 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 > 0:
        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