結果

問題 No.1594 Three Classes
ユーザー KnotsKnots
提出日時 2021-07-20 00:14:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,059 bytes
コンパイル時間 1,989 ms
コンパイル使用メモリ 202,396 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-28 00:41:56
合計ジャッジ時間 3,506 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

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; }

const int INF = (1<<30)-1;
const int MOD = 1e9+7;
const ll LINF = (1ll<<62)-1;

#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"
#define COUT16(x) cout << fixed << setprecision(16) << (x) << "\n";

int power3[20];

int main(){
    //input
    int n;cin >> n;
    vector<int> e(n);
    REP(i,n){
        cin >> e[i];
    }
    power3[0] = 1;
	for (int i=1;i<=n;i++) power3[i] = 3*power3[i-1];
    //3-bit-search
    for(int bit=0;bit<power3[n];bit++){
        int sumA=0,sumB=0,sumC=0;
        for(int i=0;i<n;i++){
            int j = (bit/power3[i])%3;
            if(j==0)sumA+=e[i];
            else if(j==1)sumB+=e[i];
            else sumC+=e[i];
        }
        if(sumA==sumB&&sumB==sumC){
            COUT("Yes");
            return 0;
        }
    }
    COUT("No");
}
0