結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2017-10-16 18:25:16 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 711 bytes |
コンパイル時間 | 670 ms |
コンパイル使用メモリ | 81,912 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 20:59:37 |
合計ジャッジ時間 | 1,518 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 WA * 12 |
ソースコード
#include <iostream> #include <queue> #include <vector> #include <cmath> #include <algorithm> #include <map> #include <numeric> using namespace std; using ll = long long; const ll INF = 1e9; const ll MOD = 1e9 + 7; int W[110]; bool dp[110][5010]; int main() { int N, sum = 0; cin >> N; for (int i = 0; i < N; i++) { cin >> W[i]; sum += W[i]; } if (sum % 2 > 0) { cout << "impossible" << endl; return 0; } int w = sum / 2; for (int i = 0; i < N; i++) { dp[i+1][W[i]] = true; for (int v = 0; v < w; v++) { dp[i+1][v] = true; } } cout << (dp[N][w] ? "possible" : "impossible") << endl; return 0; }