結果

問題 No.4 おもりと天秤
ユーザー minatominato
提出日時 2019-12-26 17:41:01
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 1,023 bytes
コンパイル時間 1,779 ms
コンパイル使用メモリ 174,604 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 03:52:16
合計ジャッジ時間 2,475 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////
bool A[101][21000];
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> W(N);
    rep(i,N) cin >> W[i];

    A[0][10100] = true;
    rep(i,N) {
        rep(j,21000) {
            if (j >= W[i] && A[i][j]) A[i+1][j-W[i]] = true;
            if (j < 21000 - W[i] && A[i][j]) A[i+1][j+W[i]] = true;
        }
    }

    cout << (A[N][10100] ? "possible" : "impossible ") << endl;
}
0