結果

問題 No.1594 Three Classes
ユーザー ransewhaleransewhale
提出日時 2021-07-10 00:17:51
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 788 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 76,884 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-10 06:56:32
合計ジャッジ時間 1,555 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int n;
ll e[15];
bool ans = false;

void solve(int i, ll a, ll b, ll c){
	if(i<n){
		solve(i+1,a+e[i],b,c);
		solve(i+1,a,b+e[i],c);
		solve(i+1,a,b,c+e[i]);
	}else{
		if(a==b && b==c && c==a){
			ans = true;
		}
	}
}

int main(void){
	int i;
	std::cin >> n;
	for(i=0; i<n; ++i){
		std::cin >> e[i];
	}
	solve(0,0ll,0ll,0ll);
	std::cout << (ans?"Yes":"No") << std::endl;
	return 0;
}
0