結果

問題 No.1594 Three Classes
ユーザー wolleywolley
提出日時 2021-07-10 09:37:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 935 bytes
コンパイル時間 1,346 ms
コンパイル使用メモリ 167,440 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 00:36:07
合計ジャッジ時間 2,264 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 19 ms
5,376 KB
testcase_04 AC 20 ms
5,376 KB
testcase_05 AC 19 ms
5,376 KB
testcase_06 AC 18 ms
5,376 KB
testcase_07 AC 19 ms
5,376 KB
testcase_08 AC 18 ms
5,376 KB
testcase_09 AC 18 ms
5,376 KB
testcase_10 AC 18 ms
5,376 KB
testcase_11 AC 19 ms
5,376 KB
testcase_12 AC 19 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 19 ms
5,376 KB
testcase_15 AC 19 ms
5,376 KB
testcase_16 AC 8 ms
5,376 KB
testcase_17 AC 19 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SIZE(x) ll(x.size())
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
int N, ans;
vector<int> E(20);
vector<int> P(20);

void dfs(int n) {
    if (n == N) {
        vector<int> S(3);
        rep(i, N) {
            S[P[i]] += E[i];
        }
        if (S[0] == S[1] && S[1] == S[2]) ans++;
        return ;
    }
    rep(i, 3) {
        P[n] = i;
        dfs(n + 1);
    }
}
int main()
{
    cin >> N;
    rep(i, N) cin >> E[i];
    dfs(0);
    if (ans == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}
0