結果

問題 No.1594 Three Classes
ユーザー NanashimaNanashima
提出日時 2021-07-24 17:34:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 167,476 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 07:05:31
合計ジャッジ時間 3,844 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define INF ((1LL<<62)-(1LL<<31))
#define all(a)  (a).begin(),(a).end()
#define rall(a)  (a).rbegin(),(a).rend()
typedef long long ll;
typedef pair<ll,ll> pl;
typedef tuple<ll,ll,ll> tupl;

int main()
{
    int n;
    cin >> n;
    vector<ll> e(n),pow3(n+1);
    rep(i,n) cin >> e[i];
    pow3[0]=1;
    for(int i=1;i<=n;i++) pow3[i]=3*pow3[i-1];
    for(int bit=0;bit<pow3[n];bit++) {
        int suma=0,sumb=0,sumc=0;
        rep(i,n) {
            int j=(bit/pow3[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" << endl;
            return 0;
        }
    }
    cout << "No" << endl; 
    return 0;
}
0