結果
問題 |
No.1594 Three Classes
|
ユーザー |
![]() |
提出日時 | 2025-05-13 00:17:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 50 ms / 2,000 ms |
コード長 | 840 bytes |
コンパイル時間 | 3,253 ms |
コンパイル使用メモリ | 274,536 KB |
実行使用メモリ | 6,272 KB |
最終ジャッジ日時 | 2025-05-13 00:18:01 |
合計ジャッジ時間 | 4,987 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; inline int pow3(int n) { int res = 1; while (n--) res *= 3; return res; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; vector<int> a(n); rep(i, n) cin >> a[i]; const int p3n = pow3(n); rep(tbit, p3n) { int t = tbit; int x = 0, y = 0, z = 0; rep(i, n) { int b = t % 3; t /= 3; switch (b) { case 0: x += a[i]; break; case 1: y += a[i]; break; case 2: z += a[i]; break; } } if (x == y && y == z) { cout << "Yes" << '\n'; return 0; } } cout << "No" << '\n'; return 0; }