結果
問題 | No.1594 Three Classes |
ユーザー |
|
提出日時 | 2021-07-09 22:13:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 1,265 bytes |
コンパイル時間 | 2,053 ms |
コンパイル使用メモリ | 196,156 KB |
最終ジャッジ日時 | 2025-01-22 21:57:51 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h>using namespace std;typedef long long ll;template<typename T>ostream& operator<<(ostream &os, vector<T> &v){string sep = " ";if(v.size()) os << v[0];for(int i=1; i<v.size(); i++) os << sep << v[i];return os;}template<typename T>istream& operator>>(istream &is, vector<T> &v){for(int i=0; i<v.size(); i++) is >> v[i];return is;}#ifdef DBGvoid debug_(){ cout << endl; }template<typename T, typename... Args>void debug_(T&& x, Args&&... xs){cout << x << " "; debug_(forward<Args>(xs)...);}#define dbg(...) debug_(__VA_ARGS__)#else#define dbg(...)#endifint main() {ios_base::sync_with_stdio(false);cout << setprecision(20) << fixed;int n;cin >> n;vector<int> e(n);cin >> e;int a = reduce(e.begin(), e.end());for(int s=1; s<(1<<n); s++){for(int t=s&(s-1);; t=s&(t-1)){if(t==0) break;int x = 0;int y = 0;for(int i=0; i<n; i++){if((s^t)>>i&1) x+=e[i];if(t>>i&1) y+=e[i];}if(x==y&&x==a-x-y) {cout << "Yes" << endl;return 0;}}}cout << "No" << endl;return 0;}