結果

問題 No.231 めぐるはめぐる (1)
ユーザー masamasa
提出日時 2015-06-28 15:14:48
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 1,515 bytes
コンパイル時間 707 ms
コンパイル使用メモリ 75,916 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-07 18:40:03
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 6 ms
4,376 KB
testcase_04 AC 7 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 6 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 6 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>

using namespace std;
const int penalty = 30000;
const int need = 100 * penalty;

int main() {
	int n, g, d;
	vector< pair<int, int> > dungeon;

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> g >> d;
		dungeon.push_back(make_pair(g - d * penalty, i));
	}

	for (int i = n + 1; i <= 6; i++) {
		dungeon.push_back(make_pair(-1e8, -1));
	}
	sort(dungeon.begin(), dungeon.end(), greater<pair<int, int> >());


	if (dungeon[0].first * 6 < need) {
		cout << "NO" << endl;
		return 0;
	}

	vector<int> order(6, 1), ans;
	int point, min_point = 1e8;

	for (int i = 0; i < 6; i++) {
		order[0] = i;
	for (int j = 0; j < 6; j++) {
		order[1] = j;
	for (int k = 0; k < 6; k++) {
		order[2] = k;
	for (int x = 0; x < 6; x++) {
		order[3] = x;
	for (int y = 0; y < 6; y++) {
		order[4] = y;
	for (int z = 0; z < 6; z++) {
		order[5] = z;

		int experience = 0;
		for (int h = 0; h < 6; h++) {
			experience += dungeon[order[h]].first;
		}

		if (experience < need) {
			continue;
		}

		point = 0;
		for (int l = 0; l < 6; l++) {
			for (int m = 0; m < 6; m++) {
				if (l == m) {
					continue;
				}

				if (order[l] == order[m]) {
					int tmp = 6 - abs(l - m);
					point += tmp * tmp * tmp * tmp;
				}
			}
		}


		if (point < min_point) {
			min_point = point;
			ans = order;
		}
	}}}}}}

	cout << "YES" << endl;
	for (int i = 0; i < 6; i++) {
		cout << dungeon[ans[i]].second << endl;
	}

	return 0;
}
0