結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2022-04-03 20:31:36 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 890 bytes |
コンパイル時間 | 3,003 ms |
コンパイル使用メモリ | 172,548 KB |
最終ジャッジ日時 | 2025-01-28 14:47:06 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 14 WA * 1 RE * 8 |
ソースコード
#include <iostream> #include <string> #include <vector> #include <algorithm> #include <utility> #include <map> #include <set> #include <queue> #include <iomanip> #include <cmath> #include <atcoder/all> using namespace std; using namespace atcoder; typedef long long ll; #define rep(i,n) for (int i = 0; i < int(n);i++) int main(){ int n; cin >> n; vector<vector<bool>> dp(n+1,vector<bool> (1001)); int sum = 0; vector<int> a(n); rep(i,n){ cin >> a[i]; sum += a[i]; } dp[0][0] = true; for (int i = 0; i < n;i++){ for (int j = 0; j < 1000;j++){ if (dp[i][j]){ dp[i+1][j] = true; dp[i+1][j+a[i]] = true; } } } bool yes = false; for (int w = 0; w <= 1000;w++){ if (dp[n][w] && w*2 == sum){ yes = true; break; } } if (yes) cout << "possible" << endl; else cout << "impossible" << endl; return 0; }