結果
問題 |
No.198 キャンディー・ボックス2
|
ユーザー |
|
提出日時 | 2024-11-23 14:14:24 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 43 ms / 1,000 ms |
コード長 | 485 bytes |
コンパイル時間 | 332 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 52,736 KB |
最終ジャッジ日時 | 2024-11-23 14:14:27 |
合計ジャッジ時間 | 2,378 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
B = int(input()) N = int(input()) C = [int(input()) for _ in range(N)] low = 0 high = (sum(C)+B)//N while high-low>1e-5: l = (2*low+high)/3 r = (low+2*high)/3 ml = 0 mr = 0 for i in range(N): ml += abs(C[i]-l) mr += abs(C[i]-r) if mr>=ml: high = r else: low = l ml = 0 mr = 0 high = int(high) if high>=1: low = high-1 else: low = 0 for i in range(N): ml += abs(C[i]-low) mr += abs(C[i]-high) print(min(ml,mr))