結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  sugarrr | 
| 提出日時 | 2018-01-04 14:14:28 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 7 ms / 5,000 ms | 
| コード長 | 599 bytes | 
| コンパイル時間 | 673 ms | 
| コンパイル使用メモリ | 66,628 KB | 
| 実行使用メモリ | 5,760 KB | 
| 最終ジャッジ日時 | 2024-06-26 10:26:25 | 
| 合計ジャッジ時間 | 1,278 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
typedef long long ll;
using namespace std;
int main(){
    int n;cin>>n;
    int w[n+1];for(int i=1;i<=n;i++)cin>>w[i];
    bool dp[n+1][22001];
    for(int i=0;i<=22000;i++)dp[0][i]=false;
    dp[0][11000]=true;
    for(int i=1;i<=n;i++)for(int j=0;j<=22000;j++){
        dp[i][j]=(dp[i-1][j+w[i]]||dp[i-1][j-w[i]]);
    }
   if(dp[n][11000]==true)printf("possible");
    else printf("impossible");
    return 0;
}
            
            
            
        