結果

問題 No.1594 Three Classes
ユーザー erbowlerbowl
提出日時 2022-09-17 11:16:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 902 bytes
コンパイル時間 1,967 ms
コンパイル使用メモリ 200,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-23 17:35:11
合計ジャッジ時間 3,963 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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[j];
            }
            if(tmp1==sum/3){
                std::cout << "Yes" << std::endl;
                return 0;
            }
        }
    }
    std::cout << "No" << std::endl;
}
0