結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2022-09-28 15:09:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 40 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 1,966 ms |
コンパイル使用メモリ | 195,372 KB |
最終ジャッジ日時 | 2025-02-07 17:52:09 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector<int> E(N); rep(i,N) cin >> E[i]; rep(S,1<<N) { for(int T = S;; T = (T - 1) & S) { int Pa = 0, Pb = 0, Pc = 0; rep(i,N) { if(S & (1 << i)) { if(T & (1 << i)) Pa += E[i]; else Pb += E[i]; } else Pc += E[i]; } if(Pa == Pb && Pb == Pc) { cout << "Yes" << endl; return 0; } if(T == 0) break; } } cout << "No" << endl; return 0; }