結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-03 16:22:56 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 583 bytes |
| コンパイル時間 | 1,678 ms |
| コンパイル使用メモリ | 171,260 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-14 01:58:34 |
| 合計ジャッジ時間 | 2,423 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 WA * 3 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<int>v(n);
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> v[i];
sum += v[i];
}
if (sum & 1) {
cout << "impossible" << endl;
exit(0);
}
vector<bool>dp(sum + 1, false);
dp[sum] = true;
for (int i = 0; i < n; i++) {
for (int j = sum; j >= 0; j--) {
if (dp[j] && j - v[i] >= 0) {
dp[j - v[i]] = true;
}
}
}
if (dp[sum / 2])
cout << "possible" << endl;
else
cout << "impossible" << endl;
}