結果

問題 No.4 おもりと天秤
ユーザー suppy193suppy193
提出日時 2016-07-07 16:49:37
言語 C90
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 440 bytes
コンパイル時間 258 ms
コンパイル使用メモリ 21,504 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 00:55:30
合計ジャッジ時間 1,071 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int main(void) {
	int i, j;
	int n, w[101];
	int total = 0;
	int memo[10001] = {0};
 
	scanf("%d", &n);
	for(i = 0;i < n;i++){
		scanf("%d", &w[i]);
		total += w[i];
	}
	for(j = 0;j < 100;j++){
		memo[w[j]] = 1;
		for(i = 0;i < 10000;i++){
			if(memo[i] == 1 && i + w[j] <= 10000){
				memo[i + w[j]] = 1;
			}
		}
	}
	if(memo[total / 2] == 1){
		printf("possible\n");
	}
	else{
		printf("impossible\n");
	}
	return 0;
}
0