結果
問題 | No.1150 シュークリームゲーム(Easy) |
ユーザー |
👑 |
提出日時 | 2024-09-14 16:47:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 662 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 86,016 KB |
最終ジャッジ日時 | 2024-09-14 16:47:17 |
合計ジャッジ時間 | 4,403 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 43 |
ソースコード
n = int(input())s, t = map(int, input().split())A = list(map(int, input().split()))s -= 1t -= 1if s < t:L = A[s + 1 : t]R = A[t + 1 :] + A[:s]R = R[::-1]else:L = A[s + 1 :] + A[:t]R = A[t + 1 : s]R = R[::-1]ans = A[s]if len(L) % 2 == 0 and len(R) % 2 == 0:ans += sum(L[: len(L) // 2])ans += sum(R[: len(R) // 2])elif len(L) % 2 == 1 and len(R) % 2 == 1:ans += sum(L[: len(L) // 2])ans += sum(R[: len(R) // 2])ans += max(L[len(L) // 2], R[len(R) // 2])else:if len(R) % 2 == 0:L, R = R, Lans += sum(L[: len(L) // 2])ans += sum(R[: len(R) // 2 + 1])print(2 * ans - sum(A))