結果

問題 No.4 おもりと天秤
ユーザー Yuki InoueYuki Inoue
提出日時 2023-12-19 00:16:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 685 bytes
コンパイル時間 2,646 ms
コンパイル使用メモリ 245,484 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2023-12-19 00:16:12
合計ジャッジ時間 3,994 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 6 ms
7,552 KB
testcase_09 AC 5 ms
7,552 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 5 ms
7,552 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    int w[N+1];
    ll tot = 0;
    rep(i,1,N+1) {
        cin >> w[i];
        tot += w[i];
    }

    int dp[N+1][10001];
    rep(i,0,N+1) rep(j,0,10001) dp[i][j] = 0;
    rep(i,0,N+1) dp[i][0] = 1;
    rep(i,1,N+1) rep(j,1,10001){
        if(j-w[i]>=0) if(dp[i-1][j-w[i]] == 1){
            dp[i][j] = 1;
        }
    }

    if(tot%2==0 && dp[N][tot/2]) {
        cout << "possible" << endl;
    }
    else cout << "impossible" << endl;
    return 0;
}
0