結果

問題 No.4 おもりと天秤
ユーザー ransewhaleransewhale
提出日時 2018-07-14 00:44:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 5,000 ms
コード長 710 bytes
コンパイル時間 1,567 ms
コンパイル使用メモリ 159,784 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-17 11:47:53
合計ジャッジ時間 2,390 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,944 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,944 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 4 ms
6,940 KB
testcase_08 AC 4 ms
6,940 KB
testcase_09 AC 4 ms
6,944 KB
testcase_10 AC 4 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 3 ms
6,944 KB
testcase_13 AC 3 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 3 ms
6,944 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 3 ms
6,940 KB
testcase_18 AC 4 ms
6,944 KB
testcase_19 AC 4 ms
6,944 KB
testcase_20 AC 4 ms
6,944 KB
testcase_21 AC 4 ms
6,940 KB
testcase_22 AC 5 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

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