結果

問題 No.837 Noelちゃんと星々2
ユーザー TakoKurageTakoKurage
提出日時 2019-06-14 23:51:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 279 ms / 2,000 ms
コード長 380 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 19,052 KB
最終ジャッジ日時 2023-09-02 07:22:31
合計ジャッジ時間 4,870 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 278 ms
18,916 KB
testcase_01 AC 279 ms
18,920 KB
testcase_02 AC 274 ms
18,876 KB
testcase_03 AC 275 ms
18,956 KB
testcase_04 AC 279 ms
18,868 KB
testcase_05 AC 275 ms
18,912 KB
testcase_06 AC 276 ms
18,908 KB
testcase_07 AC 273 ms
18,908 KB
testcase_08 AC 272 ms
19,052 KB
testcase_09 AC 16 ms
8,104 KB
testcase_10 AC 16 ms
8,284 KB
testcase_11 AC 16 ms
8,132 KB
testcase_12 AC 16 ms
8,136 KB
testcase_13 AC 16 ms
8,240 KB
testcase_14 AC 16 ms
8,100 KB
testcase_15 AC 16 ms
8,232 KB
testcase_16 AC 15 ms
8,144 KB
testcase_17 AC 16 ms
8,164 KB
testcase_18 AC 17 ms
8,260 KB
testcase_19 AC 16 ms
8,156 KB
testcase_20 AC 16 ms
8,248 KB
testcase_21 AC 17 ms
8,192 KB
testcase_22 AC 16 ms
8,160 KB
testcase_23 AC 15 ms
8,156 KB
testcase_24 AC 15 ms
8,168 KB
testcase_25 AC 15 ms
8,292 KB
testcase_26 AC 16 ms
8,120 KB
testcase_27 AC 15 ms
8,168 KB
testcase_28 AC 16 ms
8,200 KB
testcase_29 AC 15 ms
8,140 KB
testcase_30 AC 16 ms
8,276 KB
testcase_31 AC 16 ms
8,160 KB
testcase_32 AC 15 ms
8,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import accumulate

N = int(input())
Y = [int(i) for i in input().split()]
Y.sort()

A = [0] + list(accumulate(Y))

def solve(l, r):
    m = l + (r - l) // 2
    return (Y[m], Y[m] * (2 * m - l - r + 2) - 2 * A[m + 1] + A[l] + A[r])

mi = 1e20
for i in range(1, N):
    y1, a = solve(0, i)
    y2, b = solve(i, N)
    mi = min(mi, 1 if y1 == y2 else a + b)
print(mi)
0