結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー Kiri8128Kiri8128
提出日時 2020-07-12 09:54:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 637 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-04-22 10:41:43
合計ジャッジ時間 3,318 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
11,008 KB
testcase_01 AC 31 ms
10,880 KB
testcase_02 AC 31 ms
10,880 KB
testcase_03 AC 32 ms
10,880 KB
testcase_04 AC 35 ms
10,880 KB
testcase_05 AC 31 ms
10,880 KB
testcase_06 AC 31 ms
11,008 KB
testcase_07 AC 32 ms
10,880 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 31 ms
11,008 KB
testcase_12 AC 32 ms
10,880 KB
testcase_13 AC 35 ms
11,008 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
assert 1 <= N <= 10^5
s, t = map(int, input().split())
assert 1 <= s <= N
assert 1 <= t <= N
assert s != t
s, t = s-1, t-1
A = [int(a) for a in input().split()]
for a in A:
    assert 1 <= a <= 10 ** 9
su = sum(A)

if s < t:
    X = A[s+1:t]
    Y = (A[t+1:] + A[:s])[::-1]
else:
    X = A[t+1:s][::-1]
    Y = A[s+1:] + A[:t]

x, y = len(X), len(Y)

if x % 2 == y % 2 == 0:
    ans = (sum(X[:x//2] + Y[:y//2]) + A[s]) * 2 - su
elif x % 2 == y % 2 == 1:
    ans = (max(sum(X[:x//2+1] + Y[:y//2]), sum(X[:x//2] + Y[:y//2+1])) + A[s]) * 2 - su
else:
    ans = (sum(X[:(x+1)//2] + Y[:(y+1)//2]) + A[s]) * 2 - su

print(ans)
0