結果

問題 No.871 かえるのうた
ユーザー syunsukesyunsuke
提出日時 2019-08-31 22:19:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,064 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 11,068 KB
実行使用メモリ 26,264 KB
最終ジャッジ日時 2023-08-20 09:26:22
合計ジャッジ時間 4,625 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,168 KB
testcase_01 AC 17 ms
8,288 KB
testcase_02 AC 16 ms
8,332 KB
testcase_03 AC 16 ms
8,172 KB
testcase_04 AC 16 ms
8,168 KB
testcase_05 AC 16 ms
8,232 KB
testcase_06 AC 16 ms
8,144 KB
testcase_07 AC 17 ms
8,280 KB
testcase_08 AC 18 ms
8,680 KB
testcase_09 AC 19 ms
8,772 KB
testcase_10 AC 17 ms
8,156 KB
testcase_11 AC 18 ms
8,252 KB
testcase_12 AC 28 ms
11,280 KB
testcase_13 AC 20 ms
8,912 KB
testcase_14 AC 88 ms
24,696 KB
testcase_15 AC 87 ms
24,600 KB
testcase_16 AC 121 ms
26,264 KB
testcase_17 AC 82 ms
23,384 KB
testcase_18 AC 28 ms
11,000 KB
testcase_19 AC 89 ms
24,736 KB
testcase_20 AC 25 ms
9,540 KB
testcase_21 AC 46 ms
14,464 KB
testcase_22 AC 16 ms
8,224 KB
testcase_23 AC 17 ms
8,148 KB
testcase_24 AC 17 ms
8,240 KB
testcase_25 AC 18 ms
8,512 KB
testcase_26 AC 25 ms
9,732 KB
testcase_27 AC 25 ms
10,552 KB
testcase_28 AC 17 ms
8,252 KB
testcase_29 AC 48 ms
15,204 KB
testcase_30 AC 87 ms
20,168 KB
testcase_31 AC 18 ms
8,660 KB
testcase_32 AC 75 ms
18,876 KB
testcase_33 AC 81 ms
23,588 KB
testcase_34 AC 32 ms
12,584 KB
testcase_35 AC 54 ms
18,048 KB
testcase_36 AC 71 ms
21,092 KB
testcase_37 AC 57 ms
15,328 KB
testcase_38 AC 110 ms
23,860 KB
testcase_39 AC 104 ms
22,412 KB
testcase_40 AC 78 ms
16,020 KB
testcase_41 AC 17 ms
8,320 KB
testcase_42 AC 68 ms
15,916 KB
testcase_43 AC 16 ms
8,248 KB
testcase_44 AC 16 ms
8,244 KB
testcase_45 AC 17 ms
8,100 KB
testcase_46 AC 16 ms
8,248 KB
testcase_47 AC 16 ms
8,220 KB
testcase_48 AC 16 ms
8,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())
P=list(map(int,input().split()))
INF=float('inf')
P=[-INF]+P+[INF]
A=list(map(int,input().split()))
A=[0]+A+[0]


L=P[K]-A[K]
R=P[K]+A[K]
LF=1
RF=1
l=0
r=0
def Left(a):
    global R
    global L
    global LF
    global RF
    global l
    global r
    for i in range(a,10**5+5):
        if L<=P[K-i]:
            if L>P[K-i]-A[K-i]:
                L=P[K-i]-A[K-i]
            if R<P[K-i]+A[K-i]:
                R=P[K-i]+A[K-i]
                RF=1
        else:
            l=i
            LF=0
            break
#print(i)
def Right(a):
    global R
    global L
    global RF
    global LF
    global l
    global r
    for j in range(a,10**5+5):
        if R>=P[K+j]:
            if R<P[K+j]+A[K+j]:
                R=P[K+j]+A[K+j]
            if L>P[K+j]-A[K+j]:
                L=P[K+j]-A[K+j]
                LF=1
        else:
            RF=0
            r=j
            break

for k in range(10**5+5):
    if RF==1:
        Right(r)
    elif LF==1:
        Left(l)
    else:
        break
    

#print(j)
print(max(l+r-1,1))
0