結果

問題 No.91 赤、緑、青の石
ユーザー izuru_matsuura
提出日時 2016-09-22 21:13:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,157 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 167,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 07:00:10
合計ジャッジ時間 2,465 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    int R, G, B;
    void input() {
        cin >> R >> G >> B;
    }

    bool C(int x) {
        int a[] = {R - x, G - x, B - x};
        int d = 0,  r= 0;
        for (int i = 0; i < 3; i++) {
            if (a[i] >= 0) {
                r += a[i] / 2;
            } else {
                d += -a[i];
            }
        }
        return r >= d;
    }

    void solve() {
        int lb = 0, ub = 1e7 + 5;
        while (lb + 1 < ub) {
            int mid = (lb + ub) / 2;
            (C(mid) ? lb : ub) = mid;
        }
        cout << lb << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}

0