結果

問題 No.4 おもりと天秤
ユーザー CleyLCleyL
提出日時 2020-01-18 02:20:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 666 bytes
コンパイル時間 524 ms
コンパイル使用メモリ 65,552 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-08 12:33:58
合計ジャッジ時間 1,854 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
bool dp[100][10010];
int main(){
    int n;cin>>n;
    int sm = 0;
    int a[n];
    for(int i = 0; n > i; i++){
        cin>>a[i];
        sm += a[i];
    }
    if(sm%2){
        cout << "impossible" << endl;
        return 0;
    }
    dp[0][a[0]] = true;
    for(int i = 1; n > i; i++){
        for(int j = 0; 10000 >= j; j++){
            if(dp[i-1][j])dp[i][j] = true;
            if(a[i]>=j && dp[i-1][a[i]-j])dp[i][j] = true;
        }
    }
    for(int i = 0; n > i; i++){
        if(dp[i][sm/2]){
            cout << "possible" << endl;
            return 0;
        }
    }
    cout << "impossible" << endl;
    
}
0