結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
suppy193
|
| 提出日時 | 2016-07-07 16:10:05 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 413 bytes |
| コンパイル時間 | 134 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2024-10-12 23:13:48 |
| 合計ジャッジ時間 | 6,587 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 5 TLE * 1 -- * 17 |
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
main.c:25:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d", &w[i]);
| ^~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <stdlib.h>
int n, w[101];
int total = 0;
int dfs(int i, int sum)
{
if(sum * 2 == total){
printf("possible\n");
exit(0);
}
if(i >= n || sum * 2 > total){
return 0;
}
dfs(i + 1, sum);
dfs(i + 1, sum + w[i]);
}
int main(void) {
int i;
scanf("%d", &n);
for(i = 0;i < n;i++){
scanf("%d", &w[i]);
total += w[i];
}
dfs(1, w[0]);
printf("impossible\n");
return 0;
}
suppy193