結果

問題 No.4 おもりと天秤
ユーザー togari_takamoto
提出日時 2015-12-13 01:48:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 816 bytes
コンパイル時間 1,185 ms
コンパイル使用メモリ 89,520 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 11:00:11
合計ジャッジ時間 1,563 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <iomanip>
#include <numeric>
#include <memory>
#include <limits.h>
#include <set>
#include <cassert>
#include <cmath>
#include <bitset>
using namespace std;

typedef long long ll;

#define REP(i,n) for(ll i=0; i<(n); ++i)
#define TEN(x) ((ll)1e##x)
#define ALL(v) (v).begin(), (v).end()

int main() {
	ll n;
	cin >> n;

	vector<ll> w(n);
	for (auto&i : w) cin >> i;
	ll sum = accumulate(ALL(w), 0);
	if (sum % 2 == 1) {
		cout << "impossible" << endl;
		return 0;
	}

	vector<bool> table(100 * 100 + 1, false); table[0] = true;
	REP(i, n) REP(j, 100 * 100 + 1 - w[i]) if(table[j]) table[j + w[i]] = true;

	cout << (table[sum / 2] ? "possible" : "impossible") << endl;
	return 0;
}
0