結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー NoaSaberNoaSaber
提出日時 2021-04-04 11:28:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 1,084 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 87,316 KB
実行使用メモリ 94,024 KB
最終ジャッジ日時 2023-08-27 07:03:35
合計ジャッジ時間 6,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
71,364 KB
testcase_01 AC 75 ms
71,444 KB
testcase_02 AC 75 ms
71,392 KB
testcase_03 AC 75 ms
71,336 KB
testcase_04 AC 75 ms
71,352 KB
testcase_05 AC 74 ms
71,300 KB
testcase_06 AC 75 ms
71,592 KB
testcase_07 AC 76 ms
71,340 KB
testcase_08 AC 74 ms
71,532 KB
testcase_09 AC 77 ms
71,404 KB
testcase_10 AC 76 ms
71,396 KB
testcase_11 AC 73 ms
71,412 KB
testcase_12 AC 72 ms
71,460 KB
testcase_13 AC 73 ms
71,400 KB
testcase_14 AC 75 ms
71,352 KB
testcase_15 AC 74 ms
71,180 KB
testcase_16 AC 75 ms
71,336 KB
testcase_17 AC 76 ms
71,440 KB
testcase_18 AC 75 ms
71,532 KB
testcase_19 AC 76 ms
71,132 KB
testcase_20 AC 76 ms
71,480 KB
testcase_21 AC 75 ms
71,592 KB
testcase_22 AC 98 ms
91,444 KB
testcase_23 AC 98 ms
91,132 KB
testcase_24 AC 96 ms
89,168 KB
testcase_25 AC 97 ms
89,572 KB
testcase_26 AC 98 ms
92,640 KB
testcase_27 AC 99 ms
92,216 KB
testcase_28 AC 100 ms
92,288 KB
testcase_29 AC 98 ms
90,496 KB
testcase_30 AC 97 ms
90,344 KB
testcase_31 AC 99 ms
90,604 KB
testcase_32 AC 97 ms
91,468 KB
testcase_33 AC 100 ms
91,420 KB
testcase_34 AC 99 ms
91,636 KB
testcase_35 AC 101 ms
92,736 KB
testcase_36 AC 101 ms
92,920 KB
testcase_37 AC 99 ms
93,104 KB
testcase_38 AC 97 ms
90,404 KB
testcase_39 AC 98 ms
90,768 KB
testcase_40 AC 98 ms
90,692 KB
testcase_41 AC 101 ms
93,128 KB
testcase_42 AC 99 ms
92,120 KB
testcase_43 AC 99 ms
91,852 KB
testcase_44 AC 102 ms
94,024 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]
#print(q1,q2)
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])
 #   print(X,Y,ptA)
    if pos:
        ptA+=X
        ptB=sum(q1)+sum(q2)-ptA
        print(ptA-ptB+dif)
    else:
        ptA+=Y
        ptB=sum(q1)+sum(q2)-ptA
        print(ptB-ptA+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)
    else:
        ptB=sum(q1)+sum(q2)-ptA
        print(ptB-ptA+dif)
0