結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2021-07-09 21:39:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 2,050 ms |
コンパイル使用メモリ | 168,776 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 07:37:01 |
合計ジャッジ時間 | 2,622 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #define ll long long int #define INF 1000000000000000000 using namespace std; int main(void){ ll n; cin >> n; vector<ll> e(n); for (int i = 0; i < n; i++){ cin >> e[i]; } bool ok = 0; vector<ll> tri(n, 0); auto dfs = [&](auto &dfs, int k){ if (k == n){ vector<ll> a(3, 0); for (ll i = 0; i < n; i++){ a[tri[i]] += e[i]; } if (a[0] == a[1] && a[1] == a[2]) ok = 1; return; } tri[k] = 0; dfs(dfs, k+1); tri[k] = 1; dfs(dfs, k+1); tri[k] = 2; dfs(dfs, k+1); }; dfs(dfs, 0); if (ok) cout << "Yes" << endl; else cout << "No" << endl; return 0; }