結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー uni_pythonuni_python
提出日時 2020-08-10 00:16:28
言語 PyPy3
(7.3.13)
結果
WA  
実行時間 -
コード長 1,418 bytes
コンパイル時間 1,386 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 92,736 KB
最終ジャッジ日時 2023-07-28 10:53:56
合計ジャッジ時間 7,140 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,308 KB
testcase_01 AC 71 ms
71,340 KB
testcase_02 AC 74 ms
71,060 KB
testcase_03 AC 73 ms
71,152 KB
testcase_04 AC 74 ms
70,924 KB
testcase_05 WA -
testcase_06 AC 74 ms
71,192 KB
testcase_07 WA -
testcase_08 AC 74 ms
71,152 KB
testcase_09 AC 74 ms
71,336 KB
testcase_10 AC 72 ms
71,088 KB
testcase_11 WA -
testcase_12 AC 73 ms
71,420 KB
testcase_13 AC 73 ms
71,080 KB
testcase_14 AC 73 ms
71,200 KB
testcase_15 WA -
testcase_16 AC 73 ms
71,084 KB
testcase_17 AC 73 ms
71,324 KB
testcase_18 AC 75 ms
71,400 KB
testcase_19 AC 74 ms
71,160 KB
testcase_20 AC 71 ms
71,248 KB
testcase_21 AC 72 ms
71,344 KB
testcase_22 AC 94 ms
89,204 KB
testcase_23 AC 96 ms
89,204 KB
testcase_24 AC 114 ms
88,252 KB
testcase_25 AC 98 ms
88,788 KB
testcase_26 AC 97 ms
91,728 KB
testcase_27 WA -
testcase_28 AC 119 ms
91,580 KB
testcase_29 AC 98 ms
89,348 KB
testcase_30 AC 96 ms
89,124 KB
testcase_31 AC 96 ms
88,968 KB
testcase_32 AC 116 ms
90,232 KB
testcase_33 AC 98 ms
89,612 KB
testcase_34 AC 100 ms
90,288 KB
testcase_35 WA -
testcase_36 AC 121 ms
92,736 KB
testcase_37 AC 101 ms
91,192 KB
testcase_38 AC 97 ms
89,164 KB
testcase_39 WA -
testcase_40 AC 119 ms
89,788 KB
testcase_41 AC 101 ms
91,628 KB
testcase_42 AC 96 ms
90,404 KB
testcase_43 WA -
testcase_44 AC 98 ms
91,828 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    s,t=MI()
    s-=1
    t-=1
    A=LI()
    S=sum(A)
    rev=0
    if s>t:
        s,t=t,s
        rev=1
    
    L1=A[s+1:t]
    L2=A[t+1:] + A[:s]
    
    l1=len(L1)
    l2=len(L2)
    
    X=A[s]
    
    for i in range(l1//2):
        X+=L1[i]
    for i in range(l2//2):
        X+=L2[-1-i]
        
    def calc(a,b):
        aa=abs(a-b)
        bb=N-aa
        return min(aa,bb)
            

        
    if l1%2==0 and l2%2==0:
        pass
    elif l1%2==1 and l2%2==1:
        #両方奇数なら,sとtから同じ距離の2つのうち,大きい方をとれる
        temp=[]
        for i in range(N):
            ls=calc(i,s)
            lt=calc(i,t)
            if ls==lt:
                temp.append(A[i])
        if (rev):
            X+=min(temp)
        else:
            X+=max(temp)     
        

    else:
        #片方が奇数なら,sとtから同じ距離のやつをとれる
        if not(rev):
            for i in range(N):
                ls=abs(i-s)
                lt=abs(i-t)
                if ls==lt:
                    X+=A[i]
                    break
    Y=S-X
    if not rev:
        print(X-Y)
    else:
        print(Y-X)
        
        
        
    
    


main()
0