結果

問題 No.4 おもりと天秤
ユーザー kimny
提出日時 2018-05-30 12:22:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 423 bytes
コンパイル時間 815 ms
コンパイル使用メモリ 65,104 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-30 08:12:02
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

int n;
int w[100];
int sum = 0;
bool judge[10001] = { false };

int main() {
	cin >> n;
	judge[0] = true;
	for (int i = 0; i < n; i++) {
		cin >> w[i];
		sum += w[i];
		for (int j = 10000; j >= w[i]; j--) {
			if (judge[j - w[i]]) judge[j] = true;
		}
	}
	if (sum % 2 == 0 && judge[sum / 2]) {
		cout << "possible" << endl;
	}
	else {
		cout << "impossible" << endl;
	}
	return 0;
}
0