結果

問題 No.1594 Three Classes
ユーザー siman
提出日時 2021-07-14 01:05:19
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 724 bytes
コンパイル時間 1,509 ms
コンパイル使用メモリ 141,576 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 08:29:11
合計ジャッジ時間 1,864 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <limits.h>
#include <map>
#include <queue>
#include <set>
#include <string.h>
#include <vector>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  vector<int> E(N);

  for (int i = 0; i < N; ++i) {
    cin >> E[i];
  }

  int L = pow(3, N);
  for (int mask = 0; mask < L; ++mask) {
    int powers[3] = {0, 0, 0};
    int a = mask;

    for (int i = 0; i < N; ++i) {
      int d = a % 3;

      powers[d] += E[i];
      a /= 3;
    }

    if (powers[0] == powers[1] && powers[1] == powers[2]) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}
0