#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
struct Pair {
double coeff, cost;
int id;
};
// Перебор - возвращает вектор всех последовательностей, дающих максимум:
std::vector<std::vector<int>> brute(const std::vector<Pair>& arr) {
const int n = (int)arr.size();
std::vector<int> answ(n);
for (int i = 0; i < n; ++i) {
answ[i] = i;
}
double best = -1e9;
std::vector<std::vector<int>> vars;
do {
double temp = 0;
for (int i : answ) {
(temp *= arr[i].coeff) -= arr[i].cost;
}
if (temp == best) {
vars.push_back(answ);
} else if (temp > best) {
vars.clear();
vars.push_back(answ);
best = temp;
}
} while (std::next_permutation(answ.begin(), answ.end()));
return vars;
}
// Генерация теста на 10 элементов:
void gen() {
auto file = fopen("input.txt", "wt");
fprintf(file, "10 0\n");
for (int i = 0; i < 10; ++i) {
double a = 1LL * std::rand() * std::rand() % 10000000 * 1e-6;
int b = std::rand() % 100 + 1;
fprintf(file, "%f %d\n", a, b);
}
fclose(file);
std::exit(0);
}
int main() {
//gen();
int n; scanf("%d %*d", &n);
std::vector<Pair> arr(n);
for (int i = 0; i < n; ++i) {
scanf("%lf %lf", &arr[i].coeff, &arr[i].cost);
arr[i].id = i+1;
}
for (auto& row : brute(arr)) {
printf("seq: ");
for (auto& i : row) {
printf("%d ", i+1);
}
printf("\n");
}
std::stable_sort(arr.begin(), arr.end(), [](const Pair& a, const Pair& b){
return a.coeff * b.cost - a.cost > b.coeff * a.cost - b.cost;
});
for (auto& it : arr) {
printf("%d\n", it.id);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxzdHJpbmc+CgpzdHJ1Y3QgUGFpciB7CiAgICBkb3VibGUgY29lZmYsIGNvc3Q7IAogICAgCiAgICBpbnQgaWQ7Cn07CgoKLy8g0J/QtdGA0LXQsdC+0YAgLSDQstC+0LfQstGA0LDRidCw0LXRgiDQstC10LrRgtC+0YAg0LLRgdC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B7CiAgICAgICAgcHJpbnRmKCIlZFxuIiwgaXQuaWQpOwogICAgfQogICAgCiAgICByZXR1cm4gMDsKfQ==
MTAgMAoxLjQ0MTQ4MCA3CjguMDY4MjEwIDY5CjguOTQ4NjgwIDcyCjAuMjMxMzEwIDM4CjYuNjkzNzYwIDI3CjkuMDEyOTM1IDE1CjkuNDM5OTgwIDgyCjcuMTk5MDEwIDM5CjkuNjQzMTQwIDkxCjEuODkyNDk4IDI3Cg==
10 0
1.441480 7
8.068210 69
8.948680 72
0.231310 38
6.693760 27
9.012935 15
9.439980 82
7.199010 39
9.643140 91
1.892498 27