結果
問題 | No.1594 Three Classes |
ユーザー |
![]() |
提出日時 | 2021-07-09 21:27:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 12 ms / 2,000 ms |
コード長 | 813 bytes |
コンパイル時間 | 1,535 ms |
コンパイル使用メモリ | 166,480 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-16 07:24:58 |
合計ジャッジ時間 | 2,190 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define all(x) (x).begin(),(x).end() template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;} template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;} int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0}; long double eps = 1e-9; long double pi = acos(-1); signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(20); int n; cin>>n; int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } ll ma = 1; int ans = 0; for(ll i=0;i<n;i++)ma*=3; for(ll i=0;i<ma;i++){ ll sum[3]={}; ll tmp = i; for(int j=0;j<n;j++){ sum[tmp%3] += a[j]; tmp /= 3; } if(sum[0] == sum[1] && sum[1] == sum[2])ans++; } if(ans)cout << "Yes\n"; else cout << "No\n"; }