結果

問題 No.837 Noelちゃんと星々2
ユーザー brthyyjpbrthyyjp
提出日時 2020-08-27 05:40:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 113,412 KB
最終ジャッジ日時 2023-09-02 07:32:13
合計ジャッジ時間 5,627 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
113,068 KB
testcase_01 AC 165 ms
113,268 KB
testcase_02 AC 165 ms
113,116 KB
testcase_03 AC 166 ms
113,080 KB
testcase_04 AC 167 ms
113,344 KB
testcase_05 AC 167 ms
113,072 KB
testcase_06 AC 165 ms
113,412 KB
testcase_07 AC 166 ms
113,100 KB
testcase_08 AC 166 ms
113,068 KB
testcase_09 AC 79 ms
71,516 KB
testcase_10 AC 78 ms
71,356 KB
testcase_11 AC 77 ms
71,248 KB
testcase_12 AC 79 ms
71,388 KB
testcase_13 AC 79 ms
71,396 KB
testcase_14 AC 77 ms
71,624 KB
testcase_15 AC 78 ms
71,596 KB
testcase_16 AC 78 ms
71,520 KB
testcase_17 AC 78 ms
71,528 KB
testcase_18 AC 78 ms
71,532 KB
testcase_19 AC 79 ms
71,348 KB
testcase_20 AC 79 ms
71,364 KB
testcase_21 AC 76 ms
71,528 KB
testcase_22 AC 78 ms
71,456 KB
testcase_23 AC 78 ms
71,552 KB
testcase_24 AC 79 ms
71,556 KB
testcase_25 AC 79 ms
71,564 KB
testcase_26 AC 78 ms
71,168 KB
testcase_27 AC 78 ms
71,524 KB
testcase_28 AC 79 ms
71,428 KB
testcase_29 AC 78 ms
71,452 KB
testcase_30 AC 78 ms
71,640 KB
testcase_31 AC 79 ms
71,416 KB
testcase_32 AC 82 ms
71,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
Y = list(map(int, input().split()))
Y.sort()

if len(set(Y)) == 1:
    print(1)
    exit()

from itertools import accumulate
C = [0]+Y
C = list(accumulate(C))
#print(C)

ans = 10**18
# 0~i, i+1~n-1
for i in range(n-1):
    temp = 0
    if (i+1)%2 == 1:
        m = i//2
        temp += C[i+1]-C[m+1]-(C[m]-C[0])
    else:
        m = i//2
        temp += C[i+1]-C[m+1]-(C[m+1]-C[0])
    if (n-i-1)%2 == 1:
        m = (n+i)//2
        temp += C[n]-C[m+1]-(C[m]-C[i+1])
    else:
        m = (n+i)//2
        temp += C[n]-C[m+1]-(C[m+1]-C[i+1])
    ans = min(ans, temp)
print(ans)
0