結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-07-07 16:58:44 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 554 bytes |
| コンパイル時間 | 103 ms |
| コンパイル使用メモリ | 21,628 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-12 23:15:16 |
| 合計ジャッジ時間 | 770 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
コンパイルメッセージ
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]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#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];
}
if(total % 2 == 1){
printf("impossible\n");
return 0;
}
for(j = 0;j < n;j++){
memo[w[j]] = 1;
for(i = 0;i <= 10000;i++){
if(memo[w[j]] == 1){
memo[w[j] * 2] = 1;
}
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;
}
suppy193