結果

問題 No.231 めぐるはめぐる (1)
ユーザー masamasa
提出日時 2015-06-28 14:33:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 47 ms / 1,000 ms
コード長 2,148 bytes
コンパイル時間 803 ms
コンパイル使用メモリ 78,816 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 12:11:54
合計ジャッジ時間 1,756 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 40 ms
5,376 KB
testcase_04 AC 47 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 40 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 37 ms
5,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);
	int point, max_point = 0;

	for (int i = 0; i < 6; i++) {
	for (int j = 0; j < 6; j++) {
	for (int k = 0; k < 6; k++) {
	for (int x = 0; x < 6; x++) {
	for (int y = 0; y < 6; y++) {
	for (int z = 0; z < 6; z++) {
		int experience = 0;
		experience += dungeon[i].first;
		experience += dungeon[j].first;
		experience += dungeon[k].first;
		experience += dungeon[x].first;
		experience += dungeon[y].first;
		experience += dungeon[z].first;

		if (experience < need) {
			continue;
		}

		set<int> choice1;
		choice1.insert(dungeon[i].second);
		choice1.insert(dungeon[j].second);
		choice1.insert(dungeon[k].second);
		choice1.insert(dungeon[x].second);
		choice1.insert(dungeon[y].second);
		choice1.insert(dungeon[z].second);

		vector<int> choice2(n + 1, 0);
		choice2[dungeon[i].second]++;
		choice2[dungeon[j].second]++;
		choice2[dungeon[k].second]++;
		choice2[dungeon[x].second]++;
		choice2[dungeon[y].second]++;
		choice2[dungeon[z].second]++;

		point = choice1.size() * 10000;
		point += (6 - *max_element(choice2.begin(), choice2.end())) * 100;
		point += (i != j);
		point += (j != k);
		point += (k != x);
		point += (x != y);
		point += (y != z);

		if (point > max_point) {
			max_point = point;
			order[0] = dungeon[i].second;
			order[1] = dungeon[j].second;
			order[2] = dungeon[k].second;
			order[3] = dungeon[x].second;
			order[4] = dungeon[y].second;
			order[5] = dungeon[z].second;
		}
	}}}}}}

	cout << "YES" << endl;
	for (int i = 0; i < 6; i++) {
		cout << order[i] << endl;
	}

	return 0;
}
0