結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
|
提出日時 | 2016-04-04 15:04:19 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 823 bytes |
コンパイル時間 | 678 ms |
コンパイル使用メモリ | 69,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-24 06:57:29 |
合計ジャッジ時間 | 1,710 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#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; }