結果

問題 No.91 赤、緑、青の石
ユーザー ty70
提出日時 2015-06-02 16:51:27
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 2,038 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 94,600 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-24 06:48:26
合計ジャッジ時間 1,731 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm> // require sort next_permutation count __gcd reverse etc.
#include <cstdlib> // require abs exit atof atoi
#include <cstdio> // require scanf printf
#include <functional>
#include <numeric> // require accumulate
#include <cmath> // require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip> // require setw
#include <sstream> // require stringstream
#include <cstring> // require memset
#include <cctype> // require tolower, toupper
#include <fstream> // require freopen
#include <ctime> // require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
bool check3 (int a, int b, int c, int base ){
int add1 = a - base;
int add2 = b - base;
int add3 = c - base;
if (add1 > 0 ) add1 /= 2;
if (add2 > 0 ) add2 /= 2;
if (add3 > 0 ) add3 /= 2;
return (add1 + add2 + add3 >= 0 );
}
int bin_search3 (int a, int b, int c ){
int lo = c;
int hi = a;
int res = -1;
while (lo <= hi ){
int mid = (lo + hi )/2;
if (check3 (a, b, c, mid ) ){
res = max (res, mid );
lo = mid + 1;
}else{
hi = mid - 1;
} // end if
} // end whle
return res;
}
int solve (vector<int> stone ){
int res = 0;
int cnt = (int)stone.size();
switch (cnt ){
case 0: res = 0; break;
case 1: res = stone[0]/5; break;
case 2: res = bin_search3 (stone[0], stone[1], 0 ); break;
case 3: res = bin_search3 (stone[0], stone[1], stone[2] ); break;
} // end switch
res = max (res, 0 );
return res;
}
int main()
{
ios_base::sync_with_stdio(0);
int R, G, B; cin >> R >> G >> B;
vector<int> stone; stone.clear();
if (R > 0 ) stone.push_back (R );
if (G > 0 ) stone.push_back (G );
if (B > 0 ) stone.push_back (B );
if (!stone.empty() )
sort (ALL (stone ), greater<int>() );
int res = solve (stone );
cout << res << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0