結果
| 問題 | No.1150 シュークリームゲーム(Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-08-25 09:40:46 |
| 言語 | PyPy3 (7.3.23) |
| 結果 |
AC
|
| 実行時間 | 96 ms / 2,000 ms |
| + 869µs | |
| コード長 | 1,554 bytes |
| 記録 | |
| コンパイル時間 | 284 ms |
| コンパイル使用メモリ | 95,848 KB |
| 実行使用メモリ | 99,200 KB |
| 最終ジャッジ日時 | 2026-08-25 09:41:16 |
| 合計ジャッジ時間 | 7,162 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 43 |
ソースコード
N = int(input())
s,t = map(int,input().split())
s -= 1
t -= 1
A = list(map(int,input().split()))
cnt = A[s]
if s<t:
d1 = t-s-1
d2 = N-1-t+s
if d1%2==0:
for i in range(s+1,s+d1//2+1):
cnt += A[i]
for i in range(t+d2//2+1,t+d2+1):
cnt += A[i%N]
elif d1%2==1 and d2%2==0:
for i in range(s+1,s+d1//2+2):
cnt += A[i]
for i in range(t+d2//2+1,t+d2+1):
cnt += A[i%N]
elif d1%2==1 and d2%2==1:
cnt1 = 0
for i in range(s+1,s+d1//2+2):
cnt1 += A[i]
for i in range(t+d2//2+2,t+d2+1):
cnt1 += A[i%N]
cnt2 = 0
for i in range(s+1,s+d1//2+1):
cnt2 += A[i]
for i in range(t+d2//2+1,t+d2+1):
cnt2 += A[i%N]
cnt = cnt+max(cnt1,cnt2)
else:
d2 = s-t-1
d1 = N-1-s+t
if d1%2==0:
for i in range(s+1,s+d1//2+1):
cnt += A[i%N]
for i in range(t+d2//2+1,t+d2+1):
cnt += A[i]
elif d1%2==1 and d2%2==0:
for i in range(s+1,s+d1//2+2):
cnt += A[i%N]
for i in range(t+d2//2+1,t+d2+1):
cnt += A[i]
elif d1%2==1 and d2%2==1:
cnt1 = 0
for i in range(s+1,s+d1//2+2):
cnt1 += A[i%N]
for i in range(t+d2//2+2,t+d2+1):
cnt1 += A[i]
cnt2 = 0
for i in range(s+1,s+d1//2+1):
cnt2 += A[i%N]
for i in range(t+d2//2+1,t+d2+1):
cnt2 += A[i]
cnt = cnt+max(cnt1,cnt2)
S = sum(A)
print(cnt*2-S)