結果
| 問題 | No.91 赤、緑、青の石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-04-04 15:04:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 823 bytes |
| 記録 | |
| コンパイル時間 | 459 ms |
| コンパイル使用メモリ | 74,360 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-12-07 12:25:42 |
| 合計ジャッジ時間 | 1,391 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 |
ソースコード
#include <iostream>
#include <functional>
#include <vector>
#include <cmath>
using ll = long long int;
ll BinarySearch(ll low, ll high, std::function<bool(ll)> calc){
if(high-low==1){
return low;
}
if(calc((high+low)/2)){
return BinarySearch((high+low)/2, high, calc);
}else{
return BinarySearch(low, (high+low)/2, calc);
}
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
ll R, G, B;
std::cin >> R >> G >> B;
auto calc = [=](ll n) -> bool {
std::vector<ll> stone({R-n, G-n, B-n});
ll changeableNum = 0;
for(auto i : stone){
changeableNum += (i>0) ? i/2 : i;
}
return changeableNum>=0;
};
std::cout << BinarySearch(0, std::pow(2, 24), calc) << "\n";
return 0;
}