結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
93,632 KB
testcase_01 AC 125 ms
93,392 KB
testcase_02 AC 125 ms
93,260 KB
testcase_03 AC 125 ms
93,568 KB
testcase_04 AC 126 ms
93,416 KB
testcase_05 AC 126 ms
93,708 KB
testcase_06 AC 126 ms
93,852 KB
testcase_07 AC 124 ms
93,368 KB
testcase_08 AC 127 ms
93,440 KB
testcase_09 AC 54 ms
62,848 KB
testcase_10 AC 56 ms
62,336 KB
testcase_11 AC 54 ms
62,336 KB
testcase_12 AC 53 ms
62,848 KB
testcase_13 AC 54 ms
63,232 KB
testcase_14 AC 53 ms
62,464 KB
testcase_15 AC 53 ms
62,592 KB
testcase_16 AC 53 ms
62,720 KB
testcase_17 AC 54 ms
62,336 KB
testcase_18 AC 55 ms
62,800 KB
testcase_19 AC 58 ms
62,720 KB
testcase_20 AC 54 ms
63,160 KB
testcase_21 AC 56 ms
62,332 KB
testcase_22 AC 55 ms
62,720 KB
testcase_23 AC 55 ms
62,592 KB
testcase_24 AC 53 ms
62,208 KB
testcase_25 AC 53 ms
62,720 KB
testcase_26 WA -
testcase_27 AC 54 ms
62,592 KB
testcase_28 AC 54 ms
62,592 KB
testcase_29 AC 53 ms
62,208 KB
testcase_30 AC 55 ms
62,720 KB
testcase_31 WA -
testcase_32 AC 53 ms
62,208 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(x,y,l):
    a = y-x
    if a%2 == 0:
        return a//2,l[a//2+x]
    else:
        return (a-1)//2+1,(l[(a-1)//2+x]+l[(a-1)//2+1+x])//2
ans = inf
for i in range(1,N+1):
    S[i] += S[i-1]+Y[i-1]
for i in range(1,N):
    x1,m1 = mid(0,i-1,Y)
    x2,m2 = mid(i,N-1,Y)
    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