#include <bits/stdc++.h> using namespace std; #define n 18 void read(vector<int> &a) { int x; for (int i = 0; i < n; ++i) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); } int sum(vector<int> &a) { int sum = 0; for (int i = 0; i < n; ++i) { sum += a[i]; } return sum; } int diff(vector<int> &a, vector<int> &b) { for (int i = n-1; i>=0; --i) { if (a[i] != b[i]) return i; } return -1; } int main() { vector<int> a,b; read(a); read(b); int sum_a = sum(a); int sum_b = sum(b); if (sum_a == sum_b) { int poz = diff(a, b); if (poz == -1) { cout << "remis"; return 0; } sum_a = a[poz]; sum_b = b[poz]; } if (sum_a > sum_b) { cout << "Algosia"; } else { cout << "Bajtek"; } }
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 <bits/stdc++.h> using namespace std; #define n 18 void read(vector<int> &a) { int x; for (int i = 0; i < n; ++i) { cin >> x; a.push_back(x); } sort(a.begin(), a.end()); } int sum(vector<int> &a) { int sum = 0; for (int i = 0; i < n; ++i) { sum += a[i]; } return sum; } int diff(vector<int> &a, vector<int> &b) { for (int i = n-1; i>=0; --i) { if (a[i] != b[i]) return i; } return -1; } int main() { vector<int> a,b; read(a); read(b); int sum_a = sum(a); int sum_b = sum(b); if (sum_a == sum_b) { int poz = diff(a, b); if (poz == -1) { cout << "remis"; return 0; } sum_a = a[poz]; sum_b = b[poz]; } if (sum_a > sum_b) { cout << "Algosia"; } else { cout << "Bajtek"; } } |