結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-02 03:03:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 467 bytes |
| コンパイル時間 | 1,305 ms |
| コンパイル使用メモリ | 159,256 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-26 09:09:33 |
| 合計ジャッジ時間 | 2,168 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include "bits/stdc++.h"
using namespace std;
typedef long long Int;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))
int a[100];
int dp[10000];
bool solve(int N) {
int S = 0;
REP(i, N) S += a[i];
if (S % 2 == 1) return false;
dp[0] = 1;
REP(i, N) for (int w = S / 2; w >= 0; w--) {
if (dp[w])
dp[w + a[i]] = 1;
}
return dp[S / 2];
}
int main() {
int N; cin >> N;
REP(i, N) cin >> a[i];
cout << (solve(N) ? "possible" : "impossible") << endl;
}