結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-05-18 14:58:34 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 758 bytes |
| 記録 | |
| コンパイル時間 | 2,326 ms |
| コンパイル使用メモリ | 334,256 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-18 14:58:38 |
| 合計ジャッジ時間 | 3,325 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
| 純コード判定待ち |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using i128 = __int128;
void solve() {
int N;
std::cin >> N;
int sum = 0;
std::vector<int> W(N);
for(int& x : W) {
std::cin >> x;
sum += x;
}
if(sum % 2) {
std::cout << "impossible";
return;
}
int x = sum / 2;
std::vector<bool> dp(x + 1);
dp[0] = true;
for(int i = 0; i < N; i ++) {
for(int j = x; j >= W[i]; j --) {
dp[j] = dp[j] | dp[j - W[i]];
}
}
if(dp[x]) std::cout << "possible";
else std::cout << "impossible";
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
//std::cin >> T;
while (T--) {
solve();
}
return 0;
}