結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-04-22 09:33:57 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 4 ms / 5,000 ms | 
| コード長 | 471 bytes | 
| コンパイル時間 | 4,346 ms | 
| コンパイル使用メモリ | 68,604 KB | 
| 最終ジャッジ日時 | 2025-01-09 22:24:34 | 
| ジャッジサーバーID (参考情報) | judge4 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 23 | 
ソースコード
#include <iostream>
#include <bitset>
void solve() {
    int n;
    std::cin >> n;
    int wsum = 0;
    std::bitset<20000> dp;
    dp[0] = 1;
    while (n--) {
        int w;
        std::cin >> w;
        wsum += w;
        dp |= (dp << w);
    }
    std::cout << (wsum % 2 == 0 && dp[wsum / 2] ? "possible" : "impossible")
              << std::endl;
}
int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
    return 0;
}
            
            
            
        