結果
問題 | No.972 選び方のスコア |
ユーザー | vwxyz |
提出日時 | 2024-05-02 07:02:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 221 ms / 2,000 ms |
コード長 | 469 bytes |
コンパイル時間 | 303 ms |
コンパイル使用メモリ | 82,168 KB |
実行使用メモリ | 112,312 KB |
最終ジャッジ日時 | 2024-11-22 18:52:23 |
合計ジャッジ時間 | 8,143 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
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)