結果

問題 No.4 おもりと天秤
ユーザー ransewhale
提出日時 2018-07-14 00:44:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 1,311 ms
コンパイル使用メモリ 159,608 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 05:52:38
合計ジャッジ時間 1,992 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<double, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

void add_mod(ll &a, ll b){
	a += b;
	a %= MOD;
}

void mul_mod(ll &a, ll b){
	a *= b;
	a %= MOD;
}

int main(void){
	int n,i,j,w[123],s=0;
	bool p[123][12345];
	cin >> n;
	fill(p[0],p[123],true);
	p[0][0] = false;
	for(i=0; i<n; ++i){
		cin >> w[i];
		s += w[i];
	}
	for(i=0; i<n; ++i){
		for(j=w[i]; j<=10000; ++j){
			if(!p[i][j-w[i]]){
				p[i+1][j] = false;
				p[i+1][j-w[i]] = false;
			}
		}
	}
	cout << ((s%2 || p[n][s/2])?"im":"") << "possible" << endl;
	return 0;
}
0