結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2021-07-09 21:29:27 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 51 ms / 2,000 ms |
コード長 | 763 bytes |
コンパイル時間 | 1,752 ms |
コンパイル使用メモリ | 169,492 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 07:28:43 |
合計ジャッジ時間 | 2,839 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "debug.hpp" #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; vector<ll> A(N); for (ll i = 0; i < N; i++) cin >> A[i]; string ans = "No"; for (ll i = 0; i < (1 << N); i++) { for (ll j = 0; j < (1 << N); j++) { if ((i + j) != (i | j)) continue; ll pa = 0, pb = 0, pc = 0; for (ll k = 0; k < N; k++) { if ((i >> k) & 1) pa += A[k]; else if ((j >> k) & 1) pb += A[k]; else pc += A[k]; } if (pa == pb && pb == pc) ans = "Yes"; } } cout << ans << '\n'; return 0; }