結果
| 問題 | No.4 おもりと天秤 |
| コンテスト | |
| ユーザー |
rsk0315
|
| 提出日時 | 2019-09-22 23:49:09 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 437 bytes |
| 記録 | |
| コンパイル時間 | 531 ms |
| コンパイル使用メモリ | 82,396 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-07 22:22:26 |
| 合計ジャッジ時間 | 1,575 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
ソースコード
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <bitset>
#include <numeric>
int main() {
size_t n;
scanf("%zu", &n);
std::vector<int> a(n);
for (auto& ai: a) scanf("%d", &ai);
int s = std::accumulate(a.begin(), a.end(), 0);
if (s & 1) return puts("impossible"), 0;
std::bitset<10001> dp;
dp.set(0);
for (auto ai: a) dp |= (dp << ai);
puts(dp[s/2]? "possible": "impossible");
}
rsk0315