結果

問題 No.1594 Three Classes
ユーザー Ryushi-techRyushi-tech
提出日時 2021-07-20 00:03:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,472 bytes
コンパイル時間 2,195 ms
コンパイル使用メモリ 200,972 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-10 07:05:14
合計ジャッジ時間 3,514 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 20 ms
4,380 KB
testcase_06 AC 4 ms
4,384 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 20 ms
4,380 KB
testcase_09 AC 20 ms
4,384 KB
testcase_10 AC 20 ms
4,380 KB
testcase_11 AC 20 ms
4,384 KB
testcase_12 AC 20 ms
4,384 KB
testcase_13 AC 2 ms
4,388 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 3 ms
4,380 KB
testcase_16 AC 3 ms
4,384 KB
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 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define fore(i_in,a) for (auto& i_in: a)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define cnts(x,c) count(all(x),c)
#define fio() cin.tie(nullptr);ios::sync_with_stdio(false);
#define DEBUG_CTN(v) cerr<<#v<<":";for(auto itr=v.begin();itr!=v.end();itr++) cerr<<" "<<*itr; cerr<<endl
template<class T> bool chmax(T &a, const T &b) {if (a<b) {a = b; return 1;} return 0;}
template<class T> bool chmin(T &a, const T &b) {if (a>b) {a = b; return 1;} return 0;}
template<class T> void print(const T &t) {cout<<t<<"\n";}
template<class T> void PRINT(const T &t) {rep(i,sz(t)) cout<<t[i]<<" \n"[i==sz(t)-1];}
const ll INF = 1LL << 62;
const int iINF = 1 << 30;

int n;
using vi = vector<int>;

int main() {
    fio(); cin>>n;
    ll su=0;
    vi a(n); fore(x,a) cin>>x,su+=x;
    rep(i,1<<n){
        ll c1=0;
        vi b;
        rep(j,n){
            if(i&(1<<j)) c1+=a[j];
            else b.emplace_back(a[j]);
        }
        int m=sz(b);
        rep(x,1<<m){
            ll c2=0;
            rep(y,m){
                if(x&(1<<y)) c2+=b[y];
            }
            if(c1==c2 and c1==su-c1-c2) {print("Yes");return 0;}
        }
    }
    print("No");
}
0