結果

問題 No.91 赤、緑、青の石
ユーザー roaris
提出日時 2019-08-08 09:29:40
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 137 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-06-24 07:20:14
合計ジャッジ時間 2,023 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

def judge(x):
    plus = []
    minus = []
    cnt = 0
    
    for i in [R, G, B]:
        if i > x:
            plus.append(i - x)
        else:
            minus.append(x - i)
    
    for plus_i in plus:
        cnt += plus_i // 2
    
    if cnt >= sum(minus):
        return True
    else:
        return False
        
def binary_search():
    left, right = 0, (R+G+B) // 3
    
    while left <= right:
        mid = (left + right) // 2
        
        if judge(mid):
            left = mid + 1
        else:
            right = mid - 1
    
    return right

R, G, B = map(int, input().split())
ans = binary_search()
print(ans)
0