結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー ntuda
提出日時 2025-07-06 22:10:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 1,499 ms
コンパイル使用メモリ 82,320 KB
実行使用メモリ 87,052 KB
最終ジャッジ日時 2025-07-06 22:10:14
合計ジャッジ時間 5,045 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
s, t = map(int, input().split())
A = list(map(int, input().split()))
s -= 1
t -= 1
A += A
X = 0
Y = 0
if t < s:
    t += N
s2 = s + N
x1 = t - s - 1
x2 = s2 - t - 1
if x1 % 2 == 1:
    a = s + x1 // 2 + 1
    if x2 % 2 == 1:
        b = t + x2 // 2 + 1
        if A[a] > A[b]:
            X += A[a]
            Y += A[b]
        else:
            X += A[b]
            Y += A[a]
    else:
        X += A[a]
else:
    if x2 % 2 == 1:
        b = t + x2 // 2 + 1
        X += A[b]
X += sum(A[s:s + x1 // 2 + 1])
X += sum(A[s2 - x2 // 2:s2])
Y += sum(A[t - x1 // 2:t + x2 // 2 + 1])
print(X - Y)
0