結果

問題 No.1594 Three Classes
ユーザー totori_nyaatotori_nyaa
提出日時 2021-07-09 21:27:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 813 bytes
コンパイル時間 1,461 ms
コンパイル使用メモリ 165,232 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-10 06:36:11
合計ジャッジ時間 2,563 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 11 ms
4,380 KB
testcase_04 AC 11 ms
4,380 KB
testcase_05 AC 11 ms
4,380 KB
testcase_06 AC 11 ms
4,380 KB
testcase_07 AC 11 ms
4,380 KB
testcase_08 AC 11 ms
4,376 KB
testcase_09 AC 11 ms
4,380 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 12 ms
4,376 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 11 ms
4,380 KB
testcase_15 AC 12 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 12 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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";
}
0