結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
stqn
|
| 提出日時 | 2014-11-25 19:34:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 691 bytes |
| コンパイル時間 | 1,278 ms |
| コンパイル使用メモリ | 159,628 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 09:04:13 |
| 合計ジャッジ時間 | 2,116 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define long int64_t
#define ulong uint64_t
const int N = 100;
int n, w[N];
void input()
{
cin >> n;
rep(i, n) cin >> w[i];
}
const int W = 10000;
int dp[W + 1] = {1};
bool solve()
{
const int s = accumulate(w, w + n, 0);
if (s % 2 != 0) return false;
rep(i, n) for (int j = W; j >= w[i]; --j) {
dp[j] |= dp[j - w[i]];
}
return dp[s / 2];
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(false);
input();
cout << (solve() ? "possible" : "impossible") << endl;
}
stqn