結果

問題 No.4 おもりと天秤
ユーザー yj1145141919yj1145141919
提出日時 2016-09-13 14:52:38
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 789 ms
コンパイル使用メモリ 23,808 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-28 13:03:45
合計ジャッジ時間 1,586 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 0 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 WA -
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 0 ms
5,376 KB
testcase_13 AC 0 ms
5,376 KB
testcase_14 AC 0 ms
5,376 KB
testcase_15 AC 0 ms
5,376 KB
testcase_16 WA -
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 1 ms
5,376 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:24:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   24 |         fgets(str, sizeof(str), stdin);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.c:27:9: warning: ignoring return value of ‘fgets’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   27 |         fgets(str, sizeof(str), stdin);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/*
 * douteki.c
 *
 *  Created on: 2016/09/13
 *      Author: admin
 */


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

int main(){
	char str[10000];
	char *tmp;
	int n=0, i=0, j=0;
	int sum_w=0, half=0;
	int w[100] = {0};
	int check[10001] = {0};

	check[0] = 1;

	fgets(str, sizeof(str), stdin);
	n = atoi(str);

	fgets(str, sizeof(str), stdin);

	tmp = strtok(str, " ");
	w[0] = atoi(tmp);
	sum_w = w[0];

	for(i = 1; i < n; i++){
		tmp = strtok(NULL, " ");
		w[i] = atoi(tmp);
		sum_w += w[i];
	}

	half = sum_w / 2;

	if(half % 2 == 1){
		printf("impossible\n");
		goto end;
	}

	for(i = 0; i < n; i++){
		for(j = sum_w; j >= 0; j--){
			if(check[j] == 1){
				check[w[i] + j] = 1;
			}
		}
	}

	if(check[half] == 1){
		printf("possible\n");
	}
	else{
		printf("impossible\n");
	}

end:
	return 0;
}
0