結果

問題 No.4 おもりと天秤
ユーザー Zu_rinZu_rin
提出日時 2020-05-06 21:37:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 683 bytes
コンパイル時間 617 ms
コンパイル使用メモリ 73,912 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 07:32:08
合計ジャッジ時間 4,739 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, sum = 0, a;
	cin >> num;
	vector<int>	dp(100 * num + 1, 0);
	dp[0] = true;
	rep(i, num) {
		cin >> a;
		sum += a;
		rep(j, dp.size()) {
			if (dp[j])
				dp[j + a] = true;
		}
	}
	if ((sum & 1) || !dp[sum >> 1])
		printf("impossible\n");
	else
		printf("possible\n");
	return 0;
}
0