結果

問題 No.837 Noelちゃんと星々2
ユーザー 👑 KazunKazun
提出日時 2021-02-07 19:52:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 461 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 93,880 KB
最終ジャッジ日時 2023-09-17 18:17:10
合計ジャッジ時間 7,786 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 82 ms
75,504 KB
testcase_11 WA -
testcase_12 AC 80 ms
75,392 KB
testcase_13 AC 79 ms
75,284 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 75 ms
71,140 KB
testcase_17 WA -
testcase_18 AC 77 ms
75,184 KB
testcase_19 AC 80 ms
75,672 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 81 ms
75,500 KB
testcase_24 AC 73 ms
71,348 KB
testcase_25 AC 74 ms
71,208 KB
testcase_26 WA -
testcase_27 AC 75 ms
71,304 KB
testcase_28 AC 73 ms
71,416 KB
testcase_29 AC 74 ms
71,132 KB
testcase_30 AC 72 ms
71,208 KB
testcase_31 WA -
testcase_32 AC 74 ms
71,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def dist(Y,a,b):
    X=0
    for y in Y:
        X+=min(abs(y-a),abs(y-b))
    return X

def solve(Y):
    Z=sorted(Y)
    M=len(Z)
    if M==1:
        return 1
    elif M==2:
        return 0

    Y.sort()

    p=M//3
    q=(M//3)*2
    A=float("inf")

    for a in range(max(p-5,0),min(p+5,M)):
        for b in range(max(q-5,0),min(q+5,M)):
            A=min(A,dist(Y,Z[a],Z[b]))
    return A

N=int(input())
Y=list(map(int,input().split()))
print(solve(Y))
0