結果

問題 No.4 おもりと天秤
ユーザー Sounds_Of_Rain
提出日時 2015-07-30 10:34:09
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 747 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 79,436 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-07-17 22:33:25
合計ジャッジ時間 7,246 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 2 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <list>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <sstream>
using namespace std;
typedef long long int llint;
const int INF = 1000000;
const llint LINF = 100000000;
int n, num[100000];
int dfs(int i,int sum1, int sum2) {
	if (i == n) { return sum1 == sum2; }
	else {
		if (dfs(i + 1, sum1 + num[i], sum2)) return 1;
		if (dfs(i + 1, sum1, sum2 + num[i])) return 1;
		return false;
	}
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) { cin >> num[i]; }
	if (dfs(0, 0, 0))cout << "possible\n";
	else cout << "inpossible\n";

	return 0;




}
0