結果

問題 No.1594 Three Classes
ユーザー N___hara
提出日時 2021-07-09 21:29:57
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 547 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 194,932 KB
最終ジャッジ日時 2025-01-22 20:55:25
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n;
  cin >> n;
  vector<int> e(n);
  for (int i=0;i<n;i++) cin >> e[i];
  int e3 = 1;
  for (int i=0;i<n;i++) {
    e3 *= 3;
  }
  bool ok = false;
  for (int i=0;i<e3;i++) {
    vector<int> ps(3,0);
    int left = i;
    for (int j=0;j<n;j++) {
      ps[left%3] += e[j];
      left /= 3;
    }
    if (ps[0] == ps[1] && ps[1] == ps[2]) {
      ok = true;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}
0