結果
問題 |
No.4 おもりと天秤
|
ユーザー |
|
提出日時 | 2020-10-01 23:56:54 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 667 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 74,120 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-07 11:00:09 |
合計ジャッジ時間 | 3,760 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 RE * 11 |
ソースコード
#include<iostream> #include<vector> using namespace std; vector<vector<bool>> dp(101,vector<bool>(10001,false)); int main(){ int n,sum = 0; cin >> n; int w[n]; for(int i=0;i < n;i++){ cin >> w[i]; sum += w[i]; } if(sum % 2 == 1) { cout << "impossible" << endl; return 0; } dp[0][0] = true; for(int i=0;i <= n;i++){ for(int j=0;j < 10000;j++){ if(dp[i][j] == true){ dp[i+1][j+w[i]] = true; dp[i+1][j] = true; } } } if(dp[n][sum/2]) cout << "possible" << endl; else cout << "impossible" << endl; return 0; }