#include <ranges> #include <vector> #include <iostream> #include <numeric> #include <algorithm> using namespace std; string result(vector<int> algosiaScores, vector<int> bajtekScores); int main() { ios_base::sync_with_stdio(false); vector<int> bScores; vector<int> aScores; int score; for (int i = 0; i < 18; i++) { cin >> score; aScores.push_back(score); } for (int i = 0; i < 18; i++) { cin >> score; bScores.push_back(score); } cout << result(aScores, bScores) << endl; return 0; } string result(vector<int> algosiaScores, vector<int> bajtekScores) { auto aScore = accumulate(algosiaScores.begin(), algosiaScores.end(), 0); auto bScore = accumulate(bajtekScores.begin(), bajtekScores.end(), 0); if (aScore != bScore) { return (aScore > bScore ? "Algosia" : "Bajtek"); } sort(algosiaScores.rbegin(), algosiaScores.rend()); sort(bajtekScores.rbegin(), bajtekScores.rend()); for (int i = 0; i < 18; i++) { if (algosiaScores[i] > bajtekScores[i]) { return "Algosia"; } if (bajtekScores[i] > algosiaScores[i]) { return "Bajtek"; } } return "remis"; }
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 | #include <ranges> #include <vector> #include <iostream> #include <numeric> #include <algorithm> using namespace std; string result(vector<int> algosiaScores, vector<int> bajtekScores); int main() { ios_base::sync_with_stdio(false); vector<int> bScores; vector<int> aScores; int score; for (int i = 0; i < 18; i++) { cin >> score; aScores.push_back(score); } for (int i = 0; i < 18; i++) { cin >> score; bScores.push_back(score); } cout << result(aScores, bScores) << endl; return 0; } string result(vector<int> algosiaScores, vector<int> bajtekScores) { auto aScore = accumulate(algosiaScores.begin(), algosiaScores.end(), 0); auto bScore = accumulate(bajtekScores.begin(), bajtekScores.end(), 0); if (aScore != bScore) { return (aScore > bScore ? "Algosia" : "Bajtek"); } sort(algosiaScores.rbegin(), algosiaScores.rend()); sort(bajtekScores.rbegin(), bajtekScores.rend()); for (int i = 0; i < 18; i++) { if (algosiaScores[i] > bajtekScores[i]) { return "Algosia"; } if (bajtekScores[i] > algosiaScores[i]) { return "Bajtek"; } } return "remis"; } |