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
#include <bits/stdc++.h>
using namespace std;

int arr1[18], arr2[18];

int main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    
    int n = 18; 
    int s1 = 0, s2 = 0;
    for(int i = 0; i < n; i++){ cin >> arr1[i]; s1 += arr1[i];}
    for(int i = 0; i < n; i++){ cin >> arr2[i]; s2 += arr2[i];}

    if(s1 > s2) cout << "Algosia";
    if(s2 > s1) cout << "Bajtek";
    if(s1 != s2) return 0;

    sort(arr1, arr1 + n, greater <int> ());
    sort(arr2, arr2 + n, greater <int> ());

    int win = 0;
    for(int i = 0; i < n; i++){
        if(!win && arr1[i] > arr2[i]) win = 1;
        if(!win && arr1[i] < arr2[i]) win = 2;
    }
    if(win == 0) cout << "remis";
    if(win == 1) cout << "Algosia";
    if(win == 2) cout << "Bajtek";
}