結果

問題 No.1594 Three Classes
ユーザー emakemak
提出日時 2021-07-09 22:13:38
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,265 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 201,224 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 06:52:38
合計ジャッジ時間 3,419 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 34 ms
4,384 KB
testcase_05 AC 35 ms
4,376 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 35 ms
4,380 KB
testcase_10 AC 35 ms
4,380 KB
testcase_11 AC 35 ms
4,384 KB
testcase_12 AC 35 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 5 ms
4,380 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 2 ms
4,380 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;
typedef long long ll;

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
    string sep = " ";
    if(v.size()) os << v[0];
    for(int i=1; i<v.size(); i++) os << sep << v[i];
    return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
    for(int i=0; i<v.size(); i++) is >> v[i];
    return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
    cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
    ios_base::sync_with_stdio(false);
    cout << setprecision(20) << fixed;

    int n;
    cin >> n;
    vector<int> e(n);
    cin >> e;

    int a = reduce(e.begin(), e.end());
    for(int s=1; s<(1<<n); s++){
        for(int t=s&(s-1);; t=s&(t-1)){
            if(t==0) break;
            int x = 0;
            int y = 0;
            for(int i=0; i<n; i++){
                if((s^t)>>i&1) x+=e[i];
                if(t>>i&1) y+=e[i];
            }
            if(x==y&&x==a-x-y) {
                cout << "Yes" << endl;
                return 0;
            }

        }
    }
    cout << "No" << endl;
    return 0;
}
0