結果

問題 No.91 赤、緑、青の石
コンテスト
ユーザー tkzw_21
提出日時 2014-12-09 20:19:57
言語 C++11(廃止可能性あり)
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 850 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 546 ms
コンパイル使用メモリ 73,536 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-07 12:20:54
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <string>
#include <map>
#include <utility>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cmath>
#define ll long long

using namespace std;


bool check(ll need,vector<ll> A){
    ll fusoku = 0;
    ll amari = 0;

    for(int i=0;i<3;i++){
        if(A[i] < need){
            fusoku += need - A[i];
        }else{
            amari += (A[i] - need)/2;
        }
    }
    if(fusoku <= amari)return true;
    return false;
}

int main(void){
	ll R,G,B;
    cin >> R >> G >> B;
    vector<ll> A{R,G,B};
    ll high = 10000000,low = 0;
    ll mid;

    while(low+1 < high){
        mid = (high+low)/2;
        // cout << mid << endl;
        if(check(mid,A))low = mid;
        else high = mid;
    }
    cout << low << endl;
    return 0;
}
0