結果

問題 No.4 おもりと天秤
ユーザー mogurocker
提出日時 2017-10-15 01:07:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 579 bytes
コンパイル時間 1,143 ms
コンパイル使用メモリ 158,820 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-17 14:55:17
合計ジャッジ時間 1,815 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
bool dp[10005];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	int sum = 0;
	dp[0] = true;
	FOR(i, n) {
		int w;
		cin >> w;
		FOR(j, 10005) {
			if (j-w >= 0) dp[j] = dp[j] || dp[j-w];
		}
		sum += w;
	}
	cout << (sum & 1 || !dp[sum/2] ? "impossible" : "possible") << endl;
	return 0;
}
0