結果

問題 No.4 おもりと天秤
ユーザー Ilag
提出日時 2020-06-15 20:05:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 167,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-03 11:32:11
合計ジャッジ時間 2,256 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool dp[11111];

int main() {
    int n;
    cin >> n;
    int w[n], sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> w[i];
        sum += w[i];
    }
    dp[0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = w[i]; j < 11111; j++) {
            dp[j] |= dp[j - w[i]];
        }
    }
    if (sum % 2 == 0 && dp[sum / 2]) cout << "possible" << endl;
    else cout << "impossible" << endl;
}
0