結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
eri
|
| 提出日時 | 2015-07-23 04:06:17 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 441 bytes |
| コンパイル時間 | 493 ms |
| コンパイル使用メモリ | 59,128 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 09:15:18 |
| 合計ジャッジ時間 | 1,307 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include<iostream>
#include<vector>
using namespace std;
int main(){
int n, sum = 0;
cin >> n;
vector<int>v(n);
for (int i = 0; i < n; i++) cin >> v[i], sum += v[i];
if (sum % 2){
cout << ("impossible") << endl; return 0;
}
vector<int>dp(sum + 1);
dp[0] = 1;
for (int i = 0; i < n; i++){
for (int j = sum; j >= v[i]; j--){
dp[j] |= dp[j - v[i]];
}
}
cout << (dp[sum / 2] ? "possible" : "impossible") << endl;
return 0;
}
eri