結果

問題 No.4 おもりと天秤
ユーザー LaikaLaika
提出日時 2019-04-05 12:19:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,631 bytes
コンパイル時間 4,694 ms
コンパイル使用メモリ 168,936 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-01 03:32:20
合計ジャッジ時間 10,745 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	int len = v.size();
    cout << '[';
	for (int i = 0; i < len; ++i) {
		s << v[i]; if (i < len-1) s << ", ";
	}
    cout << ']';
	return s;
}

bool dp[101][101];

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

	if(sum % 2){
		ppp("impossible");
		return 0;
	}

	for(int i = 0; i <= 100; ++i){
		dp[0][i] = true;
	}

	for(int i = 0; i < n; ++i){
		for(int j = 1; j <= 100; ++j){
			dp[i+1][j] = dp[i][j] or dp[i][j-w[i]];
		}
	}


	if(dp[n][sum/2]){
		ppp("possible");
	}
	else{
		ppp("impossible");
	}


    return 0;
}
0