結果
| 問題 |
No.198 キャンディー・ボックス2
|
| コンテスト | |
| ユーザー |
るこーそー
|
| 提出日時 | 2024-09-20 13:07:30 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 302 bytes |
| コンパイル時間 | 477 ms |
| コンパイル使用メモリ | 82,152 KB |
| 実行使用メモリ | 54,828 KB |
| 最終ジャッジ日時 | 2024-09-20 13:07:41 |
| 合計ジャッジ時間 | 2,514 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 14 WA * 12 |
ソースコード
b=int(input())
n=int(input())
C=[int(input()) for _ in range(n)]
def cnt(x):
return sum(abs(c-x) for c in C)
ng,ok=-1,(sum(C)+b)//n
while ok-ng>2:
mid1=(ng*2+ok)//3
mid2=(ng+ok*2)//3
if cnt(mid1)<cnt(mid2):
ok=mid2
else:
ng=mid1
print(cnt(ok) if n!=1 else 0)
るこーそー