結果

問題 No.4 おもりと天秤
ユーザー zuvizudarzuvizudar
提出日時 2016-12-24 02:32:22
言語 C90
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 473 bytes
コンパイル時間 625 ms
コンパイル使用メモリ 24,344 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-08 17:15:21
合計ジャッジ時間 4,850 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 1 ms
4,380 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 AC 0 ms
4,376 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
int main(){
	int i,j,k,ans;
	int n,w[101],total=0;
	int dp[10001];
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&w[i]);
		total+=w[i];
	}
	if(total%2!=0){
		printf("impossible");
		return 0;
	}
	int p[10001];
	for(i=0;i<10001;i++)
		p[i]=0;
	p[0]=1;
	
	int max;
	for(i=0;i<n;i++){
		for(j=max;j>=0;j--){
			if(p[j]!=0){
				p[j+w[i]]=1;
			}
		}
		max+=w[i];
	}
	

	if(p[total/2]!=0)
		printf("possible\n");
	else printf("impossible\n");

	return 0;
}
0