結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー maspy
提出日時 2020-02-02 22:26:37
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 675 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 179 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2025-12-07 12:35:27
合計ジャッジ時間 2,365 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

R,G,B = sorted(map(int,read().split()))

answer = R
G,B = G-R,B-R

def test(x,G,B):
    # x個作ることが可能である
    # まずは、G,B ともに Rに変換する場合
    if G >= x and B >= x:
        R = (G-x)//2 + (B-x)//2
        if R >= x:
            return True
    # BからR,Gに変換する場合
    B -= 2*x
    B -= max(0,2 * (x-G))
    return B >= x

left = 0 # 可能
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if test(x,G,B):
        left = x
    else:
        right = x

answer += left
print(answer)
0