0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 14:18:47 +00:00

P4025 [PA2014]Bohater

https://www.luogu.com.cn/record/88686632
This commit is contained in:
Baoshuo Ren 2022-10-05 14:06:04 +08:00
parent b921ccfe85
commit f2d3f9b475
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

73
Luogu/P4025/P4025.cpp Normal file
View File

@ -0,0 +1,73 @@
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
long long k;
std::vector<std::tuple<int, long long, long long>> up, down;
std::vector<int> ans;
cin >> n >> k;
for (int i = 1, a, b; i <= n; i++) {
cin >> a >> b;
if (b - a >= 0) up.emplace_back(i, a, b);
else down.emplace_back(i, a, b);
}
std::sort(up.begin(), up.end(), [&](const auto &a, const auto &b) {
return std::get<1>(a) < std::get<1>(b);
});
std::sort(down.begin(), down.end(), [&](const auto &a, const auto &b) {
return std::get<2>(a) > std::get<2>(b);
});
for (auto o : up) {
k -= std::get<1>(o);
if (k <= 0) {
cout << "NIE" << endl;
exit(0);
}
k += std::get<2>(o);
}
for (auto o : down) {
k -= std::get<1>(o);
if (k <= 0) {
cout << "NIE" << endl;
exit(0);
}
k += std::get<2>(o);
}
cout << "TAK" << endl;
for (auto o : up) {
cout << std::get<0>(o) << ' ';
}
for (auto o : down) {
cout << std::get<0>(o) << ' ';
}
cout << endl;
return 0;
}