結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
![]() |
提出日時 | 2014-12-09 20:19:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 762 ms |
コンパイル使用メモリ | 68,996 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 06:45:52 |
合計ジャッジ時間 | 1,777 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
ソースコード
#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; }