結果
| 問題 |
No.972 選び方のスコア
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2024-04-09 12:14:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 580 bytes |
| コンパイル時間 | 584 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 112,128 KB |
| 最終ジャッジ日時 | 2024-10-01 17:12:51 |
| 合計ジャッジ時間 | 7,732 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 WA * 2 |
ソースコード
def BinarySearch(check, yes, no, i):
while abs(yes - no) != 1:
mid = (yes + no)//2
if check(mid, i):
yes = mid
else:
no = mid
return yes
N = int(input())
A = sorted(list(map(int, input().split())))
Ac = [0] * (N + 1)
for i in range(N):
Ac[i + 1] = Ac[i] + A[i]
def check(m, i):
return A[-1-m] + A[i-m] - 2 * A[i] >= 0
ans = 0
for i in range(N):
yes = BinarySearch(check, 0, min(i, N - 1 - i) + 1, i)
ans = max(ans, Ac[-1] - Ac[-1 - yes] + Ac[i + 1] - Ac[i - yes] - (2 * yes + 1) * A[i])
print(ans)
rlangevin