結果

問題 No.243 出席番号(2)
ユーザー akakimidoriakakimidori
提出日時 2015-07-11 00:50:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 597 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 27,516 KB
実行使用メモリ 11,600 KB
最終ジャッジ日時 2023-09-22 10:42:55
合計ジャッジ時間 10,941 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int main(void){

	int N;
	scanf("%d\n",&N);

	int *W;
	W=(int *)malloc(sizeof(int)*N);

	int i;
	for(i=0;i<N;i++) scanf("%d",&W[i]);

	int sum=0;
	for(i=0;i<N;i++) sum+=W[i];

	if(sum%2!=0){
		printf("impossible\n");
		free(W);
		return 0;
	}

	char *can;
	can=(char *)malloc(sizeof(char)*(sum+1));

	for(i=0;i<=sum;i++) can[i]=0;

	can[0]=1;

	for(i=0;i<N;i++){
		int j;
		for(j=0;j<sum/2;j++){
			if(can[j]){
				can[j+W[i]]=1;
			}
		}
	}

	if(can[sum/2]){
		printf("possible\n");
	} else {
		printf("impossible\n");
	}

	free(W);
	free(can);
	return 0;
}
0