結果

問題 No.1594 Three Classes
ユーザー milanis48663220milanis48663220
提出日時 2021-07-09 21:30:43
言語 C++17
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,321 bytes
コンパイル時間 986 ms
使用メモリ 3,548 KB
最終ジャッジ日時 2022-12-17 01:35:58
合計ジャッジ時間 2,615 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 22 ms
3,388 KB
testcase_01 AC 2 ms
3,496 KB
testcase_02 AC 2 ms
3,392 KB
testcase_03 AC 22 ms
3,500 KB
testcase_04 AC 23 ms
3,548 KB
testcase_05 AC 22 ms
3,484 KB
testcase_06 AC 23 ms
3,392 KB
testcase_07 AC 22 ms
3,388 KB
testcase_08 AC 23 ms
3,536 KB
testcase_09 AC 22 ms
3,440 KB
testcase_10 AC 22 ms
3,452 KB
testcase_11 AC 23 ms
3,456 KB
testcase_12 AC 22 ms
3,388 KB
testcase_13 AC 2 ms
3,492 KB
testcase_14 AC 22 ms
3,540 KB
testcase_15 AC 22 ms
3,392 KB
testcase_16 AC 9 ms
3,384 KB
testcase_17 AC 22 ms
3,396 KB
testcase_18 AC 1 ms
3,444 KB
testcase_19 AC 2 ms
3,392 KB
testcase_20 AC 2 ms
3,500 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n; cin >> n;
    vector<int> e(n);
    for(int i = 0; i < n; i++) cin >> e[i];
    vector<int> v(n);
    bool ok = false;
    function<void(int)> dfs = [&](int i){
        if(i == n){
            vector<int> sum(3);
            for(int j = 0; j < n; j++) sum[v[j]] += e[j];
            if(sum[0] == sum[1] && sum[1] == sum[2]) ok = true;
            return;
        }
        for(int j = 0; j <= 2; j++){
            v[i] = j;
            dfs(i+1);
        }
    };
    dfs(0);
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}
0