結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-09-05 01:32:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,114 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 12,928 KB
実行使用メモリ 21,712 KB
最終ジャッジ日時 2024-11-26 21:27:53
合計ジャッジ時間 4,749 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(a, b):
    if b % 2 == 0:
        if a <= b//2:
            return 0
        else:
            return 100
    if b % 2 != 0:
        if a < (b+1)//2:
            return 0
        elif a == (b+1)//2:
            return 1
        else:
            return 100


def main():
    N = int(input())
    s, t = map(int, input().split())
    A = list(map(int, input().split()))
    if s > t:
        s = N+1-s
        t = N+1-t
        A = A[::-1]
    R = A[s:t-1]
    L = A[t:] + A[:s-1]
    L = L[::-1]
    len_R = len(R)
    len_L = len(L)
    K = (N-1)//2
    ans = A[s-1]
    Sum_A = sum(A)
    R.insert(0, 0)
    L.insert(0, 0)
    for i in range(1, len_R+1):
        R[i] += R[i-1]
    for i in range(1, len_L+1):
        L[i] += L[i-1]

    for i in range(len_R+1):
        if 0 <= K-i <= len_L:
            try_max = L[K-i] + R[i] + A[s-1]
            if try_max > ans:
                ban = 0
                ban + judge(K-i, len_L) + judge(i, len_R)
                if ban <= 1:
                    ans = try_max
    res = 2*ans - Sum_A
    print(res)
    return


if __name__ == "__main__":
    main()
0