結果

問題 No.4 おもりと天秤
コンテスト
ユーザー togari_takamoto
提出日時 2015-12-13 01:48:28
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 816 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 585 ms
コンパイル使用メモリ 111,112 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-04-04 19:21:42
合計ジャッジ時間 1,244 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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