結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  chakku | 
| 提出日時 | 2015-09-15 01:24:19 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 610 bytes | 
| コンパイル時間 | 483 ms | 
| コンパイル使用メモリ | 58,268 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-26 09:17:42 | 
| 合計ジャッジ時間 | 1,172 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;cin>>n;
    int w[101];
    int sum=0;
    for(int i=0;i<n;i++){
        cin>>w[i];
        sum += w[i];
    }
    if(sum%2){
        cout << "impossible" << endl;
        return 0;
    }
    bool score[10001];
    fill(score,score+10001,false);
    score[0]=true;
    for(int i=0;i<n;i++){
        for(int j=10000;j>=0;j--){
            if(score[j]) score[j+w[i]]=true;
        }
    }
    
    if(score[sum/2]){
        cout << "possible" << endl;
    }else{
        cout << "impossible" << endl;
    }
   
    return 0;
}
            
            
            
        