結果

問題 No.4 おもりと天秤
ユーザー 09SEPGR
提出日時 2017-10-22 00:00:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 2,075 ms
コンパイル使用メモリ 70,924 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-21 12:42:15
合計ジャッジ時間 1,620 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
 * main.cpp
 *
 *  Created on: 2017/10/06
 *      Author: sep
 */

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>

using namespace std;

inline int main003();
inline int main045();
inline int main004();
inline int main4();

int main() {

		main004();

	return 0;
}

int compare_int(const void *a, const void *b) {

	return *(int*) a - *(int*) b;

}

inline int main004() {

	int num, temp;
	int *weight;
	int i;
	int left = 0, right = 0;

	cin >> num;

	weight = new int[num];

	for (i = 0; i < num; i++) {
		cin >> weight[i];
	}

	qsort(weight, num, sizeof(int), compare_int);

	for (i = num - 1; i >= 0; i--) {

		if (left < right) {
			left += weight[i];
		} else {
			right += weight[i];
		}

	}

	if (left == right) {
		cout << "possible";
	} else {
		cout << "impossible";
	}

	return 0;
}
0