結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
togari_takamoto
|
| 提出日時 | 2015-12-13 01:56:15 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 825 bytes |
| コンパイル時間 | 720 ms |
| コンパイル使用メモリ | 90,184 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 09:21:18 |
| 合計ジャッジ時間 | 1,516 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#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) for (ll j = 100 * 100; j >= 0; --j) if (table[j]) table[j + w[i]] = true;
cout << (table[sum / 2] ? "possible" : "impossible") << endl;
return 0;
}
togari_takamoto