#include <iostream> #include <sstream> #include <vector> #include <algorithm> using namespace std; vector<int> readNumbers() { vector<int> numbers; string line; getline(cin, line); stringstream ss(line); int num; while (ss >> num) { numbers.push_back(num); } return numbers; } int sumVector(const vector<int>& vec) { int sum = 0; for (int num : vec) { sum += num; } return sum; } int main() { vector<int> r1 = readNumbers(); vector<int> r2 = readNumbers(); int suma1 = sumVector(r1); int suma2 = sumVector(r2); if (suma1 > suma2) { cout << "Algosia" << endl; } else if (suma1 < suma2) { cout << "Bajtek" << endl; } else { vector<int> sr1 = r1; vector<int> sr2 = r2; sort(sr1.begin(), sr1.end(), greater<int>()); sort(sr2.begin(), sr2.end(), greater<int>()); int maxNum = 10; while (maxNum > 0) { int count1 = count(sr1.begin(), sr1.end(), maxNum); int count2 = count(sr2.begin(), sr2.end(), maxNum); if (count1 > count2) { cout << "Algosia" << endl; return 0;} else if (count1 < count2) { cout << "Bajtek" << endl; return 0;} maxNum--; } cout <<"remis"<<endl; } 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 <sstream> #include <vector> #include <algorithm> using namespace std; vector<int> readNumbers() { vector<int> numbers; string line; getline(cin, line); stringstream ss(line); int num; while (ss >> num) { numbers.push_back(num); } return numbers; } int sumVector(const vector<int>& vec) { int sum = 0; for (int num : vec) { sum += num; } return sum; } int main() { vector<int> r1 = readNumbers(); vector<int> r2 = readNumbers(); int suma1 = sumVector(r1); int suma2 = sumVector(r2); if (suma1 > suma2) { cout << "Algosia" << endl; } else if (suma1 < suma2) { cout << "Bajtek" << endl; } else { vector<int> sr1 = r1; vector<int> sr2 = r2; sort(sr1.begin(), sr1.end(), greater<int>()); sort(sr2.begin(), sr2.end(), greater<int>()); int maxNum = 10; while (maxNum > 0) { int count1 = count(sr1.begin(), sr1.end(), maxNum); int count2 = count(sr2.begin(), sr2.end(), maxNum); if (count1 > count2) { cout << "Algosia" << endl; return 0;} else if (count1 < count2) { cout << "Bajtek" << endl; return 0;} maxNum--; } cout <<"remis"<<endl; } return 0; } |