#include <iostream> constexpr uint32_t NUM_SCORES = 11; constexpr uint32_t NUM_TASKS = 18; constexpr auto Algosia = "Algosia"; constexpr auto Bajtek = "Bajtek"; constexpr auto Remis = "remis"; struct score { int32_t scores[NUM_SCORES] = {0}; int32_t total = 0; }; int32_t cmp(score const &a, score const &b) { int32_t total_diff = a.total - b.total; if (total_diff != 0) { return total_diff; } else { for (int i = NUM_SCORES - 1; i >= 0; --i) { auto scores_diff = a.scores[i] - b.scores[i]; if (scores_diff != 0) { return scores_diff; } } return 0; } } void load(std::istream& in, score& s) { s.total = 0; for (int32_t i = 0; i < NUM_TASKS; i++) { int32_t score; in >> score; s.scores[score] ++; s.total += score; } } void print(score & s) { std::cerr << "total : " << s.total << "\n"; for (int i = NUM_SCORES -1; i >= 0; --i) { std::cerr << "scores[" << i << "] : " << s.scores[i] << "\n"; } } void prog_main(std::istream& in, std::ostream& out) { score a, b; load(in, a); load(in, b); auto result = cmp(a, b); if (result > 0) { out << Algosia; } else if (result < 0) { out << Bajtek; } else { out << Remis; } out << std::endl; } #ifndef TEST int main(int argc, char* argv[]) { prog_main(std::cin, std::cout); return 0; } #endif
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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | #include <iostream> constexpr uint32_t NUM_SCORES = 11; constexpr uint32_t NUM_TASKS = 18; constexpr auto Algosia = "Algosia"; constexpr auto Bajtek = "Bajtek"; constexpr auto Remis = "remis"; struct score { int32_t scores[NUM_SCORES] = {0}; int32_t total = 0; }; int32_t cmp(score const &a, score const &b) { int32_t total_diff = a.total - b.total; if (total_diff != 0) { return total_diff; } else { for (int i = NUM_SCORES - 1; i >= 0; --i) { auto scores_diff = a.scores[i] - b.scores[i]; if (scores_diff != 0) { return scores_diff; } } return 0; } } void load(std::istream& in, score& s) { s.total = 0; for (int32_t i = 0; i < NUM_TASKS; i++) { int32_t score; in >> score; s.scores[score] ++; s.total += score; } } void print(score & s) { std::cerr << "total : " << s.total << "\n"; for (int i = NUM_SCORES -1; i >= 0; --i) { std::cerr << "scores[" << i << "] : " << s.scores[i] << "\n"; } } void prog_main(std::istream& in, std::ostream& out) { score a, b; load(in, a); load(in, b); auto result = cmp(a, b); if (result > 0) { out << Algosia; } else if (result < 0) { out << Bajtek; } else { out << Remis; } out << std::endl; } #ifndef TEST int main(int argc, char* argv[]) { prog_main(std::cin, std::cout); return 0; } #endif |