結果

問題 No.4 おもりと天秤
コンテスト
ユーザー kei
提出日時 2016-08-10 23:10:02
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 525 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 583 ms
コンパイル使用メモリ 83,664 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-05-07 17:18:42
合計ジャッジ時間 1,582 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int num;
	cin >> num;
	vector<int> w;
	int balance_1 = 0, balance_2 = 0;
	for (int i = 0;i < num;i++) {
		int temp; cin >> temp;
		balance_1 += temp;
		w.push_back(temp);
	}
	sort(w.begin(), w.end());

	for (int i = 0; i < num/2 ; i++) {
		balance_1 -= w[num - 1 - i];
		balance_2 += w[num - 1 - i];

		if (balance_1 == balance_2) {
			cout << "possible" << endl;
			return 0;
		}
	}

	cout << "impossible" << endl;

	return 0;
}
0