結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  coco18000 | 
| 提出日時 | 2019-12-12 22:35:26 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 789 bytes | 
| コンパイル時間 | 1,777 ms | 
| コンパイル使用メモリ | 165,828 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-25 19:28:32 | 
| 合計ジャッジ時間 | 3,156 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll) 1e15;
ll W[105];
bool dp[105][10005];
int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    REP(i, N) {
        cin >> W[i];
        sum += W[i];
    }
    memset(dp, 0, sizeof(dp));
    dp[0][0] = true;
    REP(i, N) {
        REP(j, sum) {
            if (dp[i][j]) {
                dp[i + 1][j + W[i]] = true;
                dp[i + 1][j] = true;
            }
        }
    }
    if (sum % 2 == 0 && dp[N][sum / 2])
        cout << "possible" << endl;
    else
        cout << "impossible" << endl;
    return 0;
}
            
            
            
        