結果

問題 No.972 選び方のスコア
ユーザー vwxyzvwxyz
提出日時 2024-05-02 07:02:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 224 ms / 2,000 ms
コード長 469 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,080 KB
実行使用メモリ 111,856 KB
最終ジャッジ日時 2024-05-02 07:02:39
合計ジャッジ時間 7,072 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 220 ms
103,584 KB
testcase_01 AC 224 ms
104,000 KB
testcase_02 AC 205 ms
108,948 KB
testcase_03 AC 134 ms
94,704 KB
testcase_04 AC 202 ms
111,852 KB
testcase_05 AC 199 ms
111,560 KB
testcase_06 AC 199 ms
111,248 KB
testcase_07 AC 181 ms
104,412 KB
testcase_08 AC 178 ms
110,532 KB
testcase_09 AC 175 ms
109,784 KB
testcase_10 AC 143 ms
110,036 KB
testcase_11 AC 147 ms
102,068 KB
testcase_12 AC 173 ms
102,348 KB
testcase_13 AC 164 ms
102,336 KB
testcase_14 AC 183 ms
102,092 KB
testcase_15 AC 198 ms
103,532 KB
testcase_16 AC 212 ms
103,692 KB
testcase_17 AC 210 ms
103,708 KB
testcase_18 AC 37 ms
52,768 KB
testcase_19 AC 211 ms
111,468 KB
testcase_20 AC 209 ms
111,408 KB
testcase_21 AC 217 ms
111,348 KB
testcase_22 AC 198 ms
111,856 KB
testcase_23 AC 216 ms
111,180 KB
testcase_24 AC 215 ms
111,448 KB
testcase_25 AC 40 ms
52,176 KB
testcase_26 AC 38 ms
52,732 KB
testcase_27 AC 39 ms
51,940 KB
testcase_28 AC 38 ms
52,416 KB
testcase_29 AC 38 ms
52,408 KB
testcase_30 AC 38 ms
53,048 KB
testcase_31 AC 42 ms
52,392 KB
testcase_32 AC 37 ms
52,564 KB
testcase_33 AC 43 ms
60,588 KB
testcase_34 AC 42 ms
53,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Bisect_Int(ok,ng,is_ok):
    while abs(ok-ng)>1:
        mid=(ok+ng)//2
        if is_ok(mid):
            ok=mid
        else:
            ng=mid
    return ok

N=int(input())
A=sorted(list(map(int,input().split())))
C=[0]+A
for i in range(1,N+1):
    C[i]+=C[i-1]
ans=0
for m in range(N):
    def is_ok(le):
        return le==0 or A[m-le]+A[N-le]-A[m]*2>=0
    le=Bisect_Int(0,min(m,N-m-1)+1,is_ok)
    ans=max(ans,C[N]-C[N-le]+C[m]-C[m-le]-A[m]*le*2)
print(ans)
0