結果

問題 No.837 Noelちゃんと星々2
ユーザー nomemseanomemsea
提出日時 2019-06-14 22:20:40
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 92,928 KB
最終ジャッジ日時 2024-04-26 17:09:04
合計ジャッジ時間 3,732 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 61 ms
62,464 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 56 ms
62,464 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 58 ms
62,464 KB
testcase_16 AC 57 ms
62,464 KB
testcase_17 WA -
testcase_18 AC 58 ms
62,720 KB
testcase_19 WA -
testcase_20 AC 57 ms
62,592 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 AC 54 ms
62,336 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 56 ms
62,336 KB
testcase_29 AC 57 ms
62,208 KB
testcase_30 AC 57 ms
62,464 KB
testcase_31 WA -
testcase_32 AC 56 ms
62,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N = int(input())
Y = list(map(int,input().split()))
Y.sort()
S  =[0]*(N+1)
def mid(l):
    x = len(l)-1
    if x%2 == 0:
        return x//2,l[x//2]
    else:
        return (x-1)//2+1,(l[(x-1)//2]+l[(x-1)//2+1])//2
ans = inf
for i in range(1,N+1):
    S[i] += S[i-1]+Y[i-1]
for i in range(N//2,N//2+2):
    x1,m1 = mid(Y[:i])
    x2,m2 = mid(Y[i:])
    cur = (m1*x1-S[x1])+(S[i]-S[x1]-m1*(i-x1))
    cur += (m2*x2-(S[i+x2]-S[i]))+(S[N]-S[i+x2]-m2*(N-i-x2))
    ans = min(ans,cur)
print(ans)
0