結果

問題 No.1594 Three Classes
ユーザー polyester
提出日時 2021-07-09 22:43:52
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 713 bytes
コンパイル時間 985 ms
コンパイル使用メモリ 140,156 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-16 08:21:08
合計ジャッジ時間 2,282 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int ans = 0;
  for(int bit = 1; bit < (int)pow(3, n); bit++) {
    vector<ll> sum(3, 0);
    int tmp = bit;
    for(int i = 0; i < n; i++) {
      sum[tmp % 3] += a[i];
      tmp /= 3;
    }
    if(sum[0] == sum[1] && sum[1] == sum[2]) {
      ans++;
    }
  }
  if(ans > 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}
0