結果

問題 No.91 赤、緑、青の石
ユーザー rogi52
提出日時 2022-09-27 22:36:02
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 710 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 198,348 KB
最終ジャッジ日時 2025-02-07 17:34:28
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23 MLE * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    function<int(vector<int>)> dfs = [&](vector<int> A) -> int {
        int res = *min_element(A.begin(), A.end());
        rep(i,3) A[i] -= res;
        int argMax = max_element(A.begin(), A.end()) - A.begin();
        int argMin = min_element(A.begin(), A.end()) - A.begin();
        if(argMax == argMin || A[argMax] <= 1) return res;
        else {
            A[argMax] -= 2;
            A[argMin] += 1;
            return res + dfs(A);
        }
    };

    vector<int> A(3); rep(i,3) cin >> A[i];
    cout << dfs(A) << endl;
}
0