結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2015-02-07 00:47:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 608 bytes |
コンパイル時間 | 431 ms |
コンパイル使用メモリ | 54,496 KB |
実行使用メモリ | 13,896 KB |
最終ジャッジ日時 | 2024-06-23 10:31:40 |
合計ジャッジ時間 | 7,276 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 TLE * 1 -- * 4 |
ソースコード
#include <iostream> #define N_MAX 100 using namespace std; int N, W[N_MAX]; bool cal(int n, int s) { if (n >= N) return false; s -= W[n]; if (s == 0) return true; if (s < 0) return false; for (int i = n + 1; i < N; ++i) if (cal(i, s)) return true; return false; } bool cal(int s) { if (s & 1) return false; s /= 2; for (int i = 0; i < N; ++i) if (cal(i, s)) return true; return false; } int main() { int sum = 0; cin >> N; for (int i = 0; i < N; ++i) { cin >> W[i]; sum += W[i]; } if (cal(sum)) cout << "possible"; else cout << "impossible"; return 0; }