結果

問題 No.1594 Three Classes
ユーザー Nanashima
提出日時 2021-07-24 17:34:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 824 bytes
コンパイル時間 1,591 ms
コンパイル使用メモリ 168,528 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 08:31:14
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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