結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-07-08 13:19:30 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 475 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 21,504 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 23:26:02 |
| 合計ジャッジ時間 | 1,032 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 13 WA * 10 |
コンパイルメッセージ
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++){
for(i = w[j];i <= total;i += w[j]){
if(memo[i] == 0){
memo[i] = 1;
break;
}
}
}
if(memo[total / 2] == 1){
printf("possible\n");
}
else{
printf("impossible\n");
}
return 0;
}
suppy193