結果

問題 No.4 おもりと天秤
ユーザー whesonwheson
提出日時 2018-05-01 13:37:16
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 1,123 bytes
コンパイル時間 1,500 ms
コンパイル使用メモリ 164,172 KB
実行使用メモリ 7,660 KB
最終ジャッジ日時 2023-09-10 08:41:46
合計ジャッジ時間 2,913 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,468 KB
testcase_01 AC 3 ms
7,396 KB
testcase_02 AC 4 ms
7,660 KB
testcase_03 AC 4 ms
7,528 KB
testcase_04 AC 4 ms
7,504 KB
testcase_05 AC 5 ms
7,544 KB
testcase_06 AC 4 ms
7,400 KB
testcase_07 AC 4 ms
7,504 KB
testcase_08 AC 4 ms
7,656 KB
testcase_09 AC 4 ms
7,488 KB
testcase_10 AC 4 ms
7,432 KB
testcase_11 AC 4 ms
7,424 KB
testcase_12 AC 4 ms
7,408 KB
testcase_13 AC 4 ms
7,436 KB
testcase_14 AC 4 ms
7,416 KB
testcase_15 AC 4 ms
7,404 KB
testcase_16 AC 4 ms
7,408 KB
testcase_17 AC 4 ms
7,660 KB
testcase_18 AC 4 ms
7,428 KB
testcase_19 AC 4 ms
7,440 KB
testcase_20 AC 5 ms
7,408 KB
testcase_21 AC 4 ms
7,456 KB
testcase_22 AC 5 ms
7,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

/*************** using variables ***************/
int n;
int w[105];
int dp[105][10005];
/**********************************************/

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    REP(i, n) cin >> w[i];
    
    REP(i, 105) REP(j, 10005) dp[i][j] = -1;
    dp[0][0] = 0;
    REP(i, n){
        REP(j, 10001){
            if(dp[i][j] != -1){
                dp[i+1][j] = dp[i][j] + w[i];
                dp[i+1][j+w[i]] = dp[i][j];
            }
        }
    }

    bool flag = false;
    REP(j, 10001){
        if(dp[n][j] == j) flag = true;
    }
    if(flag) cout << "possible" << endl;
    else cout << "impossible" << endl;

}
0