#include <iostream> #include <vector> #include <algorithm> #include <numeric> int main() { std::ios_base::sync_with_stdio(false); std::vector<int> v1(18, 0); std::vector<int> v2(18, 0); for (auto i = 0; i < 18; i++) { std::cin >> v1[i]; } for (auto i = 0; i < 18; i++) { std::cin >> v2[i]; } std::sort(v1.begin(), v1.end(), std::greater<int>()); std::sort(v2.begin(), v2.end(), std::greater<int>()); const auto sum1 = std::accumulate(v1.begin(), v1.end(), 0); const auto sum2 = std::accumulate(v2.begin(), v2.end(), 0); if(sum1 > sum2) { std::cout << "Algosia\n"; return 0; } else if(sum1 < sum2) { std::cout << "Bajtek\n"; return 0; } for(auto i = 0; i < 18; i++) { if(v1[i] > v2[i]) { std::cout << "Algosia\n"; return 0; } else if(v1[i] < v2[i]) { std::cout << "Bajtek\n"; return 0; } } std::cout << "remis\n"; return 0; }
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 | #include <iostream> #include <vector> #include <algorithm> #include <numeric> int main() { std::ios_base::sync_with_stdio(false); std::vector<int> v1(18, 0); std::vector<int> v2(18, 0); for (auto i = 0; i < 18; i++) { std::cin >> v1[i]; } for (auto i = 0; i < 18; i++) { std::cin >> v2[i]; } std::sort(v1.begin(), v1.end(), std::greater<int>()); std::sort(v2.begin(), v2.end(), std::greater<int>()); const auto sum1 = std::accumulate(v1.begin(), v1.end(), 0); const auto sum2 = std::accumulate(v2.begin(), v2.end(), 0); if(sum1 > sum2) { std::cout << "Algosia\n"; return 0; } else if(sum1 < sum2) { std::cout << "Bajtek\n"; return 0; } for(auto i = 0; i < 18; i++) { if(v1[i] > v2[i]) { std::cout << "Algosia\n"; return 0; } else if(v1[i] < v2[i]) { std::cout << "Bajtek\n"; return 0; } } std::cout << "remis\n"; return 0; } |