結果

問題 No.4 おもりと天秤
ユーザー 楠元悠太楠元悠太
提出日時 2023-04-14 19:45:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 798 bytes
コンパイル時間 795 ms
コンパイル使用メモリ 95,500 KB
実行使用メモリ 813,996 KB
最終ジャッジ日時 2024-04-18 17:25:47
合計ジャッジ時間 2,602 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <utility>
#include <deque>
#include <iterator>
#include <cstdlib>
#include <cmath>
#include<map>
#include<tuple>
#include<iomanip>
using namespace std;
using ll = long long;
typedef pair<int, int> edge;

int main() {
	int n, w[109], sum = 0;
	int dp[109][10009];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> w[i];
		sum += w[i];
	}
	if (sum % 2 != 0) {
		cout << "impossible" << endl;
		return 0;
	}
	vector<int> s;
	s.push_back(0);
	for (int i = 1; i <= n; i++) {
		int q = s.size();
		for (int j = 0; j < q; j++) {
			int p = s[j] + w[i];
			if (p * 2 == sum) {
				cout << "possible" << endl;
				return 0;
			}
			s.push_back(p);
		}
	}
	cout << "impossible" << endl;
}
0