結果

問題 No.4 おもりと天秤
ユーザー dnish
提出日時 2016-12-31 00:00:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 1,543 ms
コンパイル使用メモリ 157,784 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-16 04:18:42
合計ジャッジ時間 2,406 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 15 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	int N,sum=0;
	cin>>N;
	int W[N];
	bool dp[100*N+101];
	for(int i=0;i<N;i++){
		cin>>W[i];
		sum+=W[i];
	}
	if(sum%2){
		printf("impossible\n");
		return 0;
	}
	
	dp[0]=true;
	for(int i=0;i<N;i++){
		for(int j=0;j<100*N+101-W[i];j++){
			dp[j+W[i]] =true;
			dp[j]=true;
		}
	}
	
	if(dp[sum/2]==true) printf("possible\n");
	else printf("impossible\n");
	return 0;
}
0