結果
| 問題 |
No.231 めぐるはめぐる (1)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-28 14:33:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 1,000 ms |
| コード長 | 2,148 bytes |
| コンパイル時間 | 961 ms |
| コンパイル使用メモリ | 78,560 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 23:37:11 |
| 合計ジャッジ時間 | 1,636 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 |
ソースコード
#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;
}