結果
| 問題 | 
                            No.91 赤、緑、青の石
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-05-03 17:45:32 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 616 bytes | 
| コンパイル時間 | 717 ms | 
| コンパイル使用メモリ | 65,628 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-24 07:14:29 | 
| 合計ジャッジ時間 | 1,611 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 28 | 
ソースコード
#include<iostream>
using namespace std;
int v[3];
bool check(int n){
    int R[3];
    long long changeable = 0;
    for(int i = 0; i < 3; i++){
        R[i] = v[i]-n;
        changeable += (R[i] > 0) ? R[i]/2 : R[i];
    }  
    return changeable >= 0;
}
int binarySearch(int low, int high){ // includes low, excludes high
    if(low == high-1)   return low;
    int mid = (low+high)/2;
    if(check(mid)){
        return binarySearch(mid, high);
    }else{
        return binarySearch(low, mid);
    }
}
int main(){
    cin >> v[0] >> v[1] >> v[2];
    cout << binarySearch(0, 1<<24) << endl;
    return 0;
}