#include <algorithm> #include <iostream> #include <vector> using ll = long long; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; std::vector<std::pair<bool, int>> ranking(n); for (int i = 0; i < n; ++i) { std::string yesno; int nfinals; std::cin >> yesno >> nfinals; ranking[i] = {yesno == "TAK", nfinals}; } std::vector<int> guys; for (int i = 0; i < n && guys.size() < 20; ++i) { auto [wants, nfinals] = ranking[i]; int nguys = guys.size(); if (nguys < 10) { if (wants) { guys.push_back(i); } } else { if (wants && nfinals < 2) { guys.push_back(i); } } } for (int dude : guys) { std::cout << dude + 1 << ' '; } std::cout << '\n'; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <algorithm> #include <iostream> #include <vector> using ll = long long; int main() { std::ios_base::sync_with_stdio(0); std::cin.tie(0); int n; std::cin >> n; std::vector<std::pair<bool, int>> ranking(n); for (int i = 0; i < n; ++i) { std::string yesno; int nfinals; std::cin >> yesno >> nfinals; ranking[i] = {yesno == "TAK", nfinals}; } std::vector<int> guys; for (int i = 0; i < n && guys.size() < 20; ++i) { auto [wants, nfinals] = ranking[i]; int nguys = guys.size(); if (nguys < 10) { if (wants) { guys.push_back(i); } } else { if (wants && nfinals < 2) { guys.push_back(i); } } } for (int dude : guys) { std::cout << dude + 1 << ' '; } std::cout << '\n'; } |