結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  ry0u_yd | 
| 提出日時 | 2015-08-29 16:36:38 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 1,084 bytes | 
| コンパイル時間 | 754 ms | 
| コンパイル使用メモリ | 70,300 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-26 09:17:31 | 
| 合計ジャッジ時間 | 1,498 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i,n) {
        cin >> v[i];
    }
    int sum = 0;
    rep(i,n) {
        sum += v[i];
    }
    if(sum % 2 == 1) {
        cout << "impossible" << endl;
    } else {
        bool used[100*100 + 105];
        memset(used,0,sizeof(used));
        used[0] = true;
        rep(i,n) {
            vector<int> id;
            rep(j,100*100+5) {
                if(used[j]) {
                    id.push_back(j);
                }
            }
            rep(j,id.size()) {
                used[id[j] + v[i]] = true;
            }
        }
        if(used[sum/2]) cout << "possible" << endl;
        else cout << "impossible" << endl;
    }
    return 0;
}
            
            
            
        