結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  幸せウサギ | 
| 提出日時 | 2019-04-16 17:55:17 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 487 bytes | 
| コンパイル時間 | 513 ms | 
| コンパイル使用メモリ | 63,080 KB | 
| 実行使用メモリ | 7,628 KB | 
| 最終ジャッジ日時 | 2024-09-22 08:20:06 | 
| 合計ジャッジ時間 | 1,289 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 13 WA * 10 | 
ソースコード
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int N=0,all=0,w1=0;
int W[110]={0};
int dp[110][10010]={0};
int main(void){
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>W[i];
		all+=W[i];
	}
	w1=all/2;
	if(all%2!=0){}
	else{
		for(int i=0;i<N;i++){
			dp[i+1][W[i]]=1;
			for(int j=1;j<5001;j++){
				if(dp[i][j-W[i]]!=0){
					dp[i+1][j]=1;
				}
			}
		}
	}
	if(dp[N][w1]==1){cout<<"possible"<<endl;}
	else{cout<<"impossible"<<endl;}
	return 0;
}
            
            
            
        