結果

問題 No.4 おもりと天秤
ユーザー Series_205Series_205
提出日時 2019-10-22 19:09:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 417 bytes
コンパイル時間 528 ms
コンパイル使用メモリ 68,268 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 20:24:11
合計ジャッジ時間 1,590 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
using namespace std;
int n,w[100],sum,x[10000];
int main(){
    cin>>n;
    x[0]=1;
    for(int i=0;i<n;i++){
        cin>>w[i];
        sum+=w[i];
    }
    if(sum%2){
        cout<<"impossible\n";
        return 0;
    }
    for(int i=0;i<n;i++){
        for(int j=w[i];j<=sum/2;j++){
            x[j]=(x[j-w[i]]|x[j]);
        }
    }
    cout<<(x[sum/2]?"":"im")<<"possible\n";
    return 0;
}
0