結果

問題 No.1594 Three Classes
ユーザー korogisukorogisu
提出日時 2021-07-10 20:40:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 170 ms / 2,000 ms
コード長 1,161 bytes
コンパイル時間 1,730 ms
コンパイル使用メモリ 172,340 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-28 00:38:46
合計ジャッジ時間 4,832 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 167 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 167 ms
6,944 KB
testcase_04 AC 167 ms
6,940 KB
testcase_05 AC 167 ms
6,940 KB
testcase_06 AC 169 ms
6,944 KB
testcase_07 AC 168 ms
6,940 KB
testcase_08 AC 170 ms
6,940 KB
testcase_09 AC 167 ms
6,944 KB
testcase_10 AC 166 ms
6,944 KB
testcase_11 AC 167 ms
6,940 KB
testcase_12 AC 167 ms
6,944 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 168 ms
6,944 KB
testcase_15 AC 167 ms
6,944 KB
testcase_16 AC 53 ms
6,940 KB
testcase_17 AC 167 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 7 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i, n) for (int i = (int)(n); i >= 0; i--)
#define rep(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = (a); i >= (int)(n); i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
using ll = long long;
using vi = vector<int>;
using vii = vector<vector<int>>;
using P = pair<int, int>;

int N;
vector<int> E;

string tenToThree(int E) {
    string three = "";
    REP(i,N) {
        three = to_string(E%3) + three;
        E /= 3;
    }
    return three;
}

int main() {
    cin >> N;
    E.resize(N);
    for (int i = 0; i < N; i++) cin >> E[i];
    
    int n = pow(3,N);
    bool ans = false;
    REP(i,n) {
        int A = 0, B = 0, C = 0;
        // 3進数に変換
        string T = tenToThree(i);
        REP(j,N) {
            char p = T[j];
            if(p == '0') A += E[j];
            if(p == '1') B += E[j];
            if(p == '2') C += E[j];
        }
        if(A == B && B == C) ans = true;
    }
    
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}
0