結果

問題 No.1594 Three Classes
ユーザー lynmisakuralynmisakura
提出日時 2021-07-09 21:35:01
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 1,805 ms
コンパイル使用メモリ 200,508 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 06:41:34
合計ジャッジ時間 3,093 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

// code by lynmisakura. wish to be accepted!
#include<bits/stdc++.h>
using namespace std;

#define REP(i,N) for(int i = 0;i < N;i++)
using ll = long long;

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  
  int N;
  cin >> N;
  vector<int> E(N);
  REP(i,N) cin >> E[i];

  REP(sup,(1<<N)){
    int A = [&](){
      int res = 0;
      REP(i,N) if(!(sup >> i & 1)) res += E[i];
      return res;
    }();
    int B = 0,C = 0;
    int sub = sup;
    do{
      B = 0,C = 0;
      REP(i,N)if(sup >> i & 1){
        if(sub >> i & 1) B += E[i];
        else C += E[i];
      } 
      if(A == B && B == C){
        cout << "Yes" << '\n';
        return 0;
      }
      sub = (sub - 1) & sup;
    }while(sub != sup);
  }
  cout << "No" << '\n';

}

0