結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー Chihaya_chanChihaya_chan
提出日時 2020-09-05 01:33:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 1,115 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 21,776 KB
最終ジャッジ日時 2024-05-05 04:02:20
合計ジャッジ時間 3,880 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,880 KB
testcase_01 AC 27 ms
10,880 KB
testcase_02 AC 28 ms
11,008 KB
testcase_03 AC 26 ms
11,008 KB
testcase_04 AC 27 ms
10,880 KB
testcase_05 AC 25 ms
10,880 KB
testcase_06 AC 29 ms
10,880 KB
testcase_07 AC 28 ms
10,880 KB
testcase_08 AC 26 ms
10,752 KB
testcase_09 AC 28 ms
10,880 KB
testcase_10 AC 27 ms
11,008 KB
testcase_11 AC 27 ms
10,752 KB
testcase_12 AC 25 ms
10,880 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 26 ms
10,880 KB
testcase_15 AC 27 ms
10,880 KB
testcase_16 AC 26 ms
10,752 KB
testcase_17 AC 26 ms
10,880 KB
testcase_18 AC 27 ms
10,880 KB
testcase_19 AC 26 ms
10,880 KB
testcase_20 AC 27 ms
10,880 KB
testcase_21 AC 25 ms
10,880 KB
testcase_22 AC 74 ms
20,252 KB
testcase_23 AC 90 ms
20,352 KB
testcase_24 AC 72 ms
19,740 KB
testcase_25 AC 81 ms
20,148 KB
testcase_26 AC 85 ms
21,192 KB
testcase_27 AC 95 ms
21,496 KB
testcase_28 AC 90 ms
21,708 KB
testcase_29 AC 85 ms
19,764 KB
testcase_30 AC 90 ms
20,524 KB
testcase_31 AC 85 ms
20,324 KB
testcase_32 AC 69 ms
20,284 KB
testcase_33 AC 84 ms
20,684 KB
testcase_34 AC 85 ms
20,944 KB
testcase_35 AC 82 ms
21,184 KB
testcase_36 AC 83 ms
21,484 KB
testcase_37 AC 100 ms
21,704 KB
testcase_38 AC 84 ms
19,944 KB
testcase_39 AC 77 ms
19,832 KB
testcase_40 AC 90 ms
20,480 KB
testcase_41 AC 86 ms
21,360 KB
testcase_42 AC 95 ms
18,808 KB
testcase_43 AC 91 ms
19,332 KB
testcase_44 AC 74 ms
21,776 KB
権限があれば一括ダウンロードができます

ソースコード

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