結果

問題 No.972 選び方のスコア
ユーザー AEnAEn
提出日時 2023-04-17 21:51:36
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 410 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,160 KB
実行使用メモリ 110,844 KB
最終ジャッジ日時 2024-04-20 23:57:19
合計ジャッジ時間 6,151 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 171 ms
102,040 KB
testcase_01 AC 166 ms
102,108 KB
testcase_02 AC 150 ms
107,216 KB
testcase_03 AC 101 ms
91,064 KB
testcase_04 AC 157 ms
110,080 KB
testcase_05 AC 158 ms
110,172 KB
testcase_06 AC 151 ms
110,168 KB
testcase_07 AC 136 ms
106,548 KB
testcase_08 AC 124 ms
108,644 KB
testcase_09 AC 122 ms
108,992 KB
testcase_10 AC 110 ms
108,600 KB
testcase_11 AC 118 ms
102,004 KB
testcase_12 AC 153 ms
102,036 KB
testcase_13 AC 136 ms
102,168 KB
testcase_14 AC 157 ms
102,136 KB
testcase_15 AC 158 ms
102,116 KB
testcase_16 AC 149 ms
102,212 KB
testcase_17 AC 154 ms
102,108 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 35 ms
54,376 KB
testcase_26 AC 34 ms
52,948 KB
testcase_27 AC 34 ms
53,420 KB
testcase_28 AC 33 ms
52,740 KB
testcase_29 AC 34 ms
53,268 KB
testcase_30 AC 33 ms
52,860 KB
testcase_31 AC 34 ms
52,200 KB
testcase_32 AC 33 ms
52,924 KB
testcase_33 AC 40 ms
59,484 KB
testcase_34 AC 35 ms
53,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
a = list(map(int, input().split()))
a.sort()

b = [0]*(N+1)
for i in range(1,N+1):
    b[i] += b[i-1]+a[i-1]
res = 0
for i in range(1,N-1):
    ok,ng = 0,min(i,N-1-i)+1
    while ng-ok>1:
        mid = (ok+ng)//2
        if b[i]-b[i-mid]+b[N]-b[N-mid]-2*mid*a[i]>0:
            ok = mid
        else:
            ng = mid
    res = max(res,b[i]-b[i-ok]+b[N]-b[N-ok]-2*ok*a[i])
print(res)
    
0