結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
using namespace std;
using namespace atcoder;
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define ll long long 
#define P pair<ll,ll>
const ll inf=1LL << 60;
ll n;
string ans;
void dfs(vector<ll> &a,ll pa,ll pb,ll pc,int i){
  if(i==n){
    if(pa==pb && pb==pc){
      ans="Yes";
    }
    return;
  }
  dfs(a,pa+a.at(i),pb,pc,i+1);
  dfs(a,pa,pb+a.at(i),pc,i+1);
  dfs(a,pa,pb,pc+a.at(i),i+1);
} 
int main(){
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ans="No";
  dfs(a,0,0,0,0);
  cout<< ans;
}
0