結果

問題 No.1594 Three Classes
ユーザー yamakeyamake
提出日時 2021-07-09 21:30:15
言語 C++14
(gcc 11.2.0 + boost 1.78.0)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 1,609 ms
使用メモリ 3,560 KB
最終ジャッジ日時 2022-12-17 01:35:44
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 52 ms
3,384 KB
testcase_01 AC 1 ms
3,508 KB
testcase_02 AC 1 ms
3,428 KB
testcase_03 AC 4 ms
3,452 KB
testcase_04 AC 52 ms
3,448 KB
testcase_05 AC 52 ms
3,560 KB
testcase_06 AC 2 ms
3,508 KB
testcase_07 AC 2 ms
3,556 KB
testcase_08 AC 52 ms
3,488 KB
testcase_09 AC 52 ms
3,540 KB
testcase_10 AC 54 ms
3,500 KB
testcase_11 AC 52 ms
3,452 KB
testcase_12 AC 52 ms
3,456 KB
testcase_13 AC 2 ms
3,504 KB
testcase_14 AC 9 ms
3,536 KB
testcase_15 AC 8 ms
3,388 KB
testcase_16 AC 5 ms
3,488 KB
testcase_17 AC 4 ms
3,560 KB
testcase_18 AC 1 ms
3,372 KB
testcase_19 AC 2 ms
3,448 KB
testcase_20 AC 2 ms
3,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define debug(output) if(debugFlag)cout<<#output<<"= "<<output<<endl
using lint = long long;
typedef pair<int,int> P;
const bool debugFlag=true;
const lint linf=1e18+7;
const lint inf=1e9+7;
const int MOD=1000000007;
signed main(){
  int n;cin>>n;
  vector<lint> e(n);
  rep(i,n)cin>>e[i];
  auto judge=[&](vector<int> const& status){
    vector<lint> a(3,0);
    rep(i,n)a[status[i]-1]+=e[i];
    sort(a.begin(),a.end());
    if(a[0]==a[2]){
      cout<<"Yes"<<"\n";
      exit(0);
    }
  };
  auto rec=[&](auto& rec,vector<int> status,int cur)->void{
    if(cur==n){
      judge(status);
      return;
    }
    rep1(i,3){
      status[cur]=i;
      rec(rec,status,cur+1);
    }
  };
  rec(rec,vector<int>(n,0),0);
  cout<<"No"<<"\n";
  return 0;
}
0