結果
| 問題 | No.4 おもりと天秤 | 
| コンテスト | |
| ユーザー |  IL_msta | 
| 提出日時 | 2015-06-03 17:51:39 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,060 bytes | 
| コンパイル時間 | 618 ms | 
| コンパイル使用メモリ | 71,372 KB | 
| 実行使用メモリ | 10,016 KB | 
| 最終ジャッジ日時 | 2024-07-06 13:54:57 | 
| 合計ジャッジ時間 | 7,160 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 18 TLE * 1 -- * 4 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#include <string>
#include <list>
/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int N;
int W[100];
bool solve(int n,int wlim){
	bool ans;
	if( n >= N){
		return false;
	}
	if(wlim == W[n]){
		//成功
		return true;
	}
	else if(wlim < W[n]){
		//失敗
		return false;
	}
	{
		ans = solve(n+1,wlim -W[n]);
		if(ans == true){
			return ans;
		}
		ans = solve(n+1,wlim );
		if(ans == true){
			return ans;
		}
	}
	return false;
}
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed;//
    //cout << setprecision(6);//
	
	
	cin>>N;//[2,100]
	
	int sum=0;
	rep(i,N){
		cin>>W[i];//[1,100]
		sum += W[i];
	}
	if(sum%2 != 0){
		P("impossible");
		return 0;
	}
	sort(W,W+N);
	bool ans = solve(0,sum/2);
	if(ans == true){
		P("possible");
	}else{
		P("impossible");
	}
	return 0;
}
            
            
            
        