結果

問題 No.4 おもりと天秤
ユーザー face4
提出日時 2018-08-16 20:07:10
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 448 bytes
コンパイル時間 574 ms
コンパイル使用メモリ 64,048 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 09:01:35
合計ジャッジ時間 1,322 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;

    bool b[10001] = {};
    b[0] = true;

    int a, sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        for(int j = 10000; j >= 0; j--) if(b[j] && j+a <= 10000)  b[j+a] = true;
        sum += a;
    }

    bool judge = sum % 2 == 0 && b[sum/2];

    if(judge)   cout << "possible" << endl;
    else        cout << "impossible" << endl;

    return 0;
}
0