結果

問題 No.4 おもりと天秤
ユーザー kidman_univkidman_univ
提出日時 2019-05-01 23:49:39
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,311 bytes
コンパイル時間 2,739 ms
コンパイル使用メモリ 81,292 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-30 04:31:05
合計ジャッジ時間 10,075 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define SP <<" "<<
//#define int ll

typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

int w[1000];

bool check(int n, int l, int r){
    if(l == r) return true;
    if(l < r) return false;
    if(n == 1) return false;
    
    //cout << n SP l SP r << endl;
    return (check(n-1, l-w[n-1] , r + w[n-1]) || check(n-1, l,r));

}

int main(){
    int n; cin >> n;
    
    int sum = 0;
    rep(i,n) {
        cin >> w[i];
        sum += w[i];
    }

    if(sum % 2 != 0){
        cout << "impossible" << endl;
        return 0;
    }

    bool ans = check(n,sum,0);

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

    

}
0