結果
問題 | No.4 おもりと天秤 |
ユーザー |
![]() |
提出日時 | 2016-07-07 15:43:30 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 391 bytes |
コンパイル時間 | 704 ms |
コンパイル使用メモリ | 20,992 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-10-12 23:06:36 |
合計ジャッジ時間 | 7,186 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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){ 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(0, 0); printf("impossible\n"); return 0; }