結果

問題 No.1594 Three Classes
コンテスト
ユーザー shiroha_F14
提出日時 2021-07-09 21:45:54
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 130 ms / 2,000 ms
+ 218µs
コード長 535 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 941 ms
コンパイル使用メモリ 183,400 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-09-24 06:45:18
合計ジャッジ時間 4,137 ms
ジャッジサーバーID
(参考情報)
judge4_1 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

#define fs(n) fixed << setprecision(n);
#define mp(a, b) make_pair(a, b);
using ll = long long;
using ld = long double;

int main(){
  int n; cin >> n;
  vector<int> e(n);
  for(int i = 0; i < n; i++) cin >> e[i];
  for(int i = 0; i < pow(3, n); i++){
    vector<int> sum(3, 0);
    for(int j = 0; j < n; j++){
      sum[(int)(i / pow(3, j)) % 3] += e[j];
    }
    if(sum[0] == sum[1] && sum[1] == sum[2]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}
0