結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー uni_pythonuni_python
提出日時 2020-08-10 00:23:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 107 ms / 2,000 ms
コード長 1,444 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 91,136 KB
最終ジャッジ日時 2024-04-15 19:52:38
合計ジャッジ時間 4,683 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,480 KB
testcase_01 AC 43 ms
52,480 KB
testcase_02 AC 42 ms
52,560 KB
testcase_03 AC 42 ms
52,096 KB
testcase_04 AC 41 ms
52,224 KB
testcase_05 AC 43 ms
52,224 KB
testcase_06 AC 43 ms
51,968 KB
testcase_07 AC 43 ms
52,096 KB
testcase_08 AC 44 ms
52,352 KB
testcase_09 AC 42 ms
51,968 KB
testcase_10 AC 43 ms
52,224 KB
testcase_11 AC 43 ms
52,480 KB
testcase_12 AC 43 ms
52,736 KB
testcase_13 AC 43 ms
52,608 KB
testcase_14 AC 43 ms
52,352 KB
testcase_15 AC 43 ms
52,352 KB
testcase_16 AC 42 ms
51,840 KB
testcase_17 AC 42 ms
52,736 KB
testcase_18 AC 42 ms
52,480 KB
testcase_19 AC 43 ms
52,608 KB
testcase_20 AC 42 ms
52,736 KB
testcase_21 AC 42 ms
52,352 KB
testcase_22 AC 71 ms
81,152 KB
testcase_23 AC 70 ms
80,640 KB
testcase_24 AC 100 ms
87,040 KB
testcase_25 AC 88 ms
86,144 KB
testcase_26 AC 74 ms
83,712 KB
testcase_27 AC 107 ms
90,368 KB
testcase_28 AC 100 ms
90,368 KB
testcase_29 AC 93 ms
86,272 KB
testcase_30 AC 75 ms
81,536 KB
testcase_31 AC 73 ms
81,152 KB
testcase_32 AC 99 ms
89,088 KB
testcase_33 AC 74 ms
81,664 KB
testcase_34 AC 75 ms
82,688 KB
testcase_35 AC 102 ms
91,136 KB
testcase_36 AC 103 ms
91,124 KB
testcase_37 AC 74 ms
83,584 KB
testcase_38 AC 74 ms
80,768 KB
testcase_39 AC 82 ms
84,608 KB
testcase_40 AC 102 ms
88,576 KB
testcase_41 AC 77 ms
83,524 KB
testcase_42 AC 75 ms
81,536 KB
testcase_43 AC 84 ms
85,888 KB
testcase_44 AC 78 ms
84,352 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# この時,Xが後手
    
    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=calc(i,s)
                lt=calc(i,t)
                if ls==lt:
                    X+=A[i]
                    break
    Y=S-X
    if not rev:
        print(X-Y)
    else:
        print(Y-X)
        
        
        
    
    


main()
0