結果

問題 No.4 おもりと天秤
ユーザー suika_psuika_p
提出日時 2019-09-23 00:16:50
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,517 bytes
コンパイル時間 1,598 ms
コンパイル使用メモリ 168,788 KB
実行使用メモリ 42,572 KB
最終ジャッジ日時 2023-10-19 07:29:10
合計ジャッジ時間 2,716 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


int dp[110][100010];
const int MAX = 100010;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> W(N); 
    int sum = 0;
    rep(i, N) {
        cin >> W[i];
        sum += W[i];
    }

    dp[0][0] = 1;

    rep(i, N) {
        rep(j, MAX) {
            if (dp[i][j] == 0) continue;
            dp[i+1][j+W[i]] += dp[i][j];
            dp[i+1][j] += dp[i][j];
        }
    }
    rep(i, MAX) {
        if (dp[N][i] == 2 && i * 2 == sum) {
            cout << "possible" << endl;
            return 0;
        }
    }
    cout << "impossible" << endl;
    return 0;
}
0