結果

問題 No.1594 Three Classes
ユーザー lynmisakuralynmisakura
提出日時 2021-07-09 21:35:01
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 202,352 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 00:00:04
合計ジャッジ時間 2,760 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 37 ms
5,376 KB
testcase_05 AC 36 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 45 ms
5,376 KB
testcase_09 AC 37 ms
5,376 KB
testcase_10 AC 40 ms
5,376 KB
testcase_11 AC 39 ms
5,376 KB
testcase_12 AC 38 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 6 ms
5,376 KB
testcase_16 AC 6 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 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