結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー NoaSaberNoaSaber
提出日時 2021-04-04 11:20:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 911 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 93,660 KB
最終ジャッジ日時 2023-08-27 06:57:02
合計ジャッジ時間 6,228 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,364 KB
testcase_01 AC 73 ms
71,356 KB
testcase_02 AC 73 ms
71,100 KB
testcase_03 AC 72 ms
71,160 KB
testcase_04 AC 73 ms
71,200 KB
testcase_05 AC 75 ms
71,312 KB
testcase_06 AC 74 ms
71,412 KB
testcase_07 AC 74 ms
71,392 KB
testcase_08 AC 74 ms
70,932 KB
testcase_09 AC 74 ms
71,360 KB
testcase_10 WA -
testcase_11 AC 76 ms
71,248 KB
testcase_12 AC 74 ms
71,148 KB
testcase_13 WA -
testcase_14 AC 74 ms
71,116 KB
testcase_15 AC 74 ms
71,316 KB
testcase_16 AC 73 ms
71,412 KB
testcase_17 AC 72 ms
71,072 KB
testcase_18 WA -
testcase_19 AC 72 ms
71,364 KB
testcase_20 WA -
testcase_21 AC 73 ms
71,204 KB
testcase_22 AC 96 ms
91,392 KB
testcase_23 WA -
testcase_24 AC 94 ms
89,016 KB
testcase_25 AC 94 ms
89,304 KB
testcase_26 AC 97 ms
92,672 KB
testcase_27 AC 100 ms
92,124 KB
testcase_28 AC 98 ms
91,992 KB
testcase_29 AC 96 ms
90,212 KB
testcase_30 AC 95 ms
90,364 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 94 ms
91,612 KB
testcase_35 AC 98 ms
92,420 KB
testcase_36 AC 100 ms
92,880 KB
testcase_37 WA -
testcase_38 AC 96 ms
90,376 KB
testcase_39 AC 95 ms
90,440 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 96 ms
91,576 KB
testcase_43 AC 95 ms
91,692 KB
testcase_44 AC 102 ms
93,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
s,t=map(int,input().split())
s-=1;t-=1
A=list(map(int,input().split()))
maxi,mini=max(s,t),min(s,t)
q1,q2,tmp=A[mini+1:maxi],A[:mini],A[maxi+1:]
q2=q2[::-1]+tmp[::-1]
dif=A[s]-A[t]
if s<t:
    pos=True
else:
    pos=False
if len(q1)%2==0 and len(q2)%2==0:
    ptA=sum(q1[:len(q1)//2])+sum(q2[:len(q2)//2])
    ptB=sum(q1)+sum(q2)-ptA
    if pos:
        print(ptA-ptB+dif)
    else:
        print(ptB-ptA+dif)
elif len(q1)%2==1 and len(q2)%2==1:
    ptA=sum(q1[:len(q1)//2])+sum(q2[:len(q2)//2])
    X,Y=max(q1[len(q1)//2],q2[len(q2)//2]),min(q1[len(q1)//2],q2[len(q2)//2])
    if pos:
        ptA+=X
    else:
        ptA+=Y
    ptB=sum(q1)+sum(q2)-ptA
    print(abs(ptA-ptB)+dif)
else:
    ptA=sum(q1[:len(q1)//2])+sum(q2[:len(q2)//2])
    if len(q1)%2==1:
        X=q1[len(q1)//2]
    else:
        X=q2[len(q2)//2]
    if pos:
        ptA+=X
    ptB=sum(q1)+sum(q2)-ptA
    print(ptA-ptB+dif)
0