結果
問題 | No.4 おもりと天秤 |
ユーザー |
|
提出日時 | 2017-05-07 13:45:21 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 406 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 58,064 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 10:15:56 |
合計ジャッジ時間 | 1,111 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
ソースコード
#include <iostream> #include <vector> auto main() -> int { int n; std::cin >> n; int sum = 0; int dp[100*100+1]; dp[0] = 1; for (int i = 0; i < n; i++) { int w; std::cin >> w; sum += w; for (int i = 100*99; i >= 0; i--) { dp[i+w] += dp[i]; } } if ((sum%2 == 0) && (dp[sum/2] != 0)) { std::cout << "possible" << std::endl; } else { std::cout << "impossible" << std::endl; } }