結果

問題 No.4 おもりと天秤
コンテスト
ユーザー vintersn0w
提出日時 2018-05-08 20:46:38
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 571 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 501 ms
コンパイル使用メモリ 94,204 KB
実行使用メモリ 11,176 KB
最終ジャッジ日時 2026-03-16 12:17:22
合計ジャッジ時間 55,678 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
#include <cmath>

using namespace std;
typedef uint uint32_t;

#define IM "impossible"
#define PO "possible"
int N;
int W[100];
int half = 0;

bool req(int idx, int w) {
    if (idx == N) return w == half;
    return req(idx+1, w+W[idx]) || req(idx+1, w);
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> W[i];
        half += W[i];
    }
    if (half % 2 != 0) cout << IM << endl;
    else {
        half /= 2;
        cout << (req(0, 0)?PO:IM) << endl;
    }
}
0