結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー titiatitia
提出日時 2020-08-07 21:52:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,673 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 12,112 KB
実行使用メモリ 21,028 KB
最終ジャッジ日時 2023-10-25 00:49:50
合計ジャッジ時間 3,850 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,180 KB
testcase_01 AC 29 ms
10,180 KB
testcase_02 AC 29 ms
10,180 KB
testcase_03 AC 30 ms
10,180 KB
testcase_04 AC 29 ms
10,180 KB
testcase_05 AC 30 ms
10,180 KB
testcase_06 AC 30 ms
10,180 KB
testcase_07 AC 30 ms
10,180 KB
testcase_08 AC 30 ms
10,180 KB
testcase_09 AC 30 ms
10,180 KB
testcase_10 AC 30 ms
10,180 KB
testcase_11 AC 30 ms
10,180 KB
testcase_12 AC 31 ms
10,180 KB
testcase_13 AC 30 ms
10,180 KB
testcase_14 AC 29 ms
10,180 KB
testcase_15 AC 29 ms
10,180 KB
testcase_16 AC 29 ms
10,180 KB
testcase_17 AC 29 ms
10,184 KB
testcase_18 AC 29 ms
10,184 KB
testcase_19 AC 29 ms
10,184 KB
testcase_20 AC 29 ms
10,184 KB
testcase_21 AC 29 ms
10,184 KB
testcase_22 AC 60 ms
19,496 KB
testcase_23 AC 59 ms
19,628 KB
testcase_24 AC 57 ms
18,884 KB
testcase_25 AC 59 ms
19,400 KB
testcase_26 AC 63 ms
20,316 KB
testcase_27 AC 62 ms
20,752 KB
testcase_28 AC 63 ms
20,980 KB
testcase_29 AC 58 ms
18,996 KB
testcase_30 AC 60 ms
19,768 KB
testcase_31 AC 60 ms
19,564 KB
testcase_32 AC 59 ms
19,448 KB
testcase_33 AC 61 ms
19,796 KB
testcase_34 AC 63 ms
20,332 KB
testcase_35 AC 63 ms
20,436 KB
testcase_36 AC 64 ms
20,880 KB
testcase_37 AC 64 ms
20,976 KB
testcase_38 AC 59 ms
19,048 KB
testcase_39 AC 59 ms
19,064 KB
testcase_40 AC 61 ms
19,740 KB
testcase_41 AC 63 ms
20,488 KB
testcase_42 AC 58 ms
16,312 KB
testcase_43 AC 57 ms
16,312 KB
testcase_44 AC 66 ms
21,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
s,t=map(int,input().split())
A=list(map(int,input().split()))

s-=1
t-=1

S1=A[s]
S2=A[t]

if s<t:
    B=A[s+1:t]
    C=A[t+1:N]+A[:s]

    #print(B,C)

    if len(B)%2==0 and len(C)%2==0:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==0 and len(C)%2==1:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==1 and len(C)%2==0:
        S1+=sum(B[:len(B)//2+1])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==1 and len(C)%2==1:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2+1])

        if B[len(B)//2]>C[len(C)//2]:
            S1+=B[len(B)//2]
        else:
            S1+=C[len(C)//2]

        print(S1-(sum(A)-S1))

else:
    C=A[t+1:s]
    B=A[s+1:N]+A[:t]

    if len(B)%2==0 and len(C)%2==0:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==0 and len(C)%2==1:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==1 and len(C)%2==0:
        S1+=sum(B[:len(B)//2+1])
        S1+=sum(C)-sum(C[:len(C)//2])

        print(S1-(sum(A)-S1))
        
    elif len(B)%2==1 and len(C)%2==1:
        S1+=sum(B[:len(B)//2])
        S1+=sum(C)-sum(C[:len(C)//2+1])

        if B[len(B)//2]>C[len(C)//2]:
            S1+=B[len(B)//2]
        else:
            S1+=C[len(C)//2]

        print(S1-(sum(A)-S1))


    
            
        
        
0