結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-01 23:58:29 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 5,000 ms |
| コード長 | 666 bytes |
| コンパイル時間 | 744 ms |
| コンパイル使用メモリ | 72,880 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-07 11:02:44 |
| 合計ジャッジ時間 | 1,531 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#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;
}