結果

問題 No.4 おもりと天秤
ユーザー MicrobeMicrobe
提出日時 2017-08-03 18:41:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 936 bytes
コンパイル時間 1,558 ms
コンパイル使用メモリ 161,388 KB
実行使用メモリ 14,008 KB
最終ジャッジ日時 2024-04-20 01:41:45
合計ジャッジ時間 7,824 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include "bits/stdc++.h"

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int N, W[101];
bool flag;

void dfs(int n, int right, int left) {
	if (n == N && right == left) {
		flag = true;
		return;
	}
	if (n < N) {
		dfs(n + 1, right + W[n], left);
		dfs(n + 1, right, left + W[n]);
	}
	return;
}

int main() {
	scanf("%d", &N);
	rep(i, N) scanf("%d", &W[i]);
	dfs(0, 0, 0);
	(flag) ? printf("possible\n") : printf("impossible\n");
	return 0;
}
0