結果
| 問題 |
No.91 赤、緑、青の石
|
| ユーザー |
ty70
|
| 提出日時 | 2015-06-02 16:35:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,367 bytes |
| コンパイル時間 | 1,116 ms |
| コンパイル使用メモリ | 95,496 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-06 13:43:37 |
| 合計ジャッジ時間 | 1,952 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 WA * 2 |
ソースコード
#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 check2 (int a, int b, int base ){
int add1 = a - base;
int add2 = b - base;
add1 /= 2;
add2 /= 2;
return (base <= add1 + add2 );
}
int bin_search2 (int a, int b ){
int lo = b;
int hi = a;
int res = -1;
while (lo <= hi ){
int mid = (lo + hi )/2;
if (check2 (a, b, mid ) ){
res = max (res, mid );
lo = mid + 1;
}else{
hi = mid - 1;
} // end if
} // end whle
return res;
}
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 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 = 0;
int cnt = (int)stone.size();
switch (cnt ){
case 0: res = 0; break;
case 1: res = stone[0]/5; break;
case 2: res = bin_search2 (stone[0], stone[1] ); break;
case 3: res = bin_search3 (stone[0], stone[1], stone[2] ); break;
} // end switch
res = max (res, 0 );
cout << res << endl;
return 0;
}
ty70