結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
![]() |
提出日時 | 2025-03-20 20:53:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 40 ms / 5,000 ms |
コード長 | 575 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,100 KB |
実行使用メモリ | 53,764 KB |
最終ジャッジ日時 | 2025-03-20 20:54:05 |
合計ジャッジ時間 | 2,684 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
R, G, B = map(int, input().split()) sum_rgb = R + G + B low = 0 high = sum_rgb // 3 best = 0 while low <= high: mid = (low + high) // 2 # Calculate deficits d_r = max(mid - R, 0) d_g = max(mid - G, 0) d_b = max(mid - B, 0) total_deficit = d_r + d_g + d_b # Calculate surplus s_r = max(R - mid, 0) s_g = max(G - mid, 0) s_b = max(B - mid, 0) total_surplus = (s_r // 2) + (s_g // 2) + (s_b // 2) if total_deficit <= total_surplus: best = mid low = mid + 1 else: high = mid - 1 print(best)