結果

問題 No.1594 Three Classes
ユーザー erbowlerbowl
提出日時 2022-09-17 11:17:38
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 902 bytes
コンパイル時間 2,018 ms
コンパイル使用メモリ 201,200 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-23 17:36:56
合計ジャッジ時間 2,992 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long


signed main(){
    ll n;
    std::cin >> n;
    vector<ll> e(n);
    ll sum = 0;
    for (int i = 0; i < n; i++) {
        std::cin >> e[i];
        sum += e[i];
    }
    
    if(sum%3!=0){
        std::cout << "No" << std::endl;
        return 0;
    }
    
    for (int i = 0; i < (1<<n); i++) {
        ll tmp = 0;
        for (int j = 0; j < n; j++) {
            if((i>>j)&1)tmp += e[j];
        }
        if(tmp!=sum/3)continue;
        for (int j = 0; j < (1<<n); j++) {
            ll tmp1 = 0;
            for (int k = 0; k < n; k++) {
                if(!((i>>k)&1)&&(j>>k)&1)tmp1 += e[k];
            }
            if(tmp1==sum/3){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
}
0