結果

問題 No.4 おもりと天秤
ユーザー 09SEPGR09SEPGR
提出日時 2017-10-22 00:00:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 2,817 ms
コンパイル使用メモリ 70,924 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 09:21:57
合計ジャッジ時間 1,777 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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