結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー 37zigen
提出日時 2020-08-08 02:20:12
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 468 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,672 KB
最終ジャッジ日時 2024-09-25 04:46:13
合計ジャッジ時間 5,158 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
s,t=map(int,input().split())
A=[int(x) for x in input().split()]
B=[A[(i+s-1)%N] for i in range(N)]
t=(t-s)%N
a,b=t-1,N-t-1
ans=2*B[0]-sum(B)
u=v=0
while 2*(u+v)<N-2:
    if 2*(u+1)<=a:
        ans+=2*B[1+u]
        u+=1
    elif 2*(v+1)<=b:
        ans+=2*B[N-1-v]
        v+=1
    else:
        add=[0]
        if 2*u<a:
            add.append(B[1+u])
        if 2*v<b:
            add.append(B[N-1-v])
        ans+=2*max(add)
        break
print(ans)
0