結果

問題 No.4 おもりと天秤
ユーザー kei
提出日時 2016-08-10 23:10:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 525 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 65,100 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-07 08:53:36
合計ジャッジ時間 1,354 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 13 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#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