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
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int alg[20];
long sum_alg;
int baj[20];
long sum_baj;
int main(){

    for(long i=0;i<18;i++){
		cin>>alg[i];
        sum_alg+=alg[i];
    }
	
    for(long i=0;i<18;i++){
		cin>>baj[i];
        sum_baj+=baj[i];
    }	

    if(sum_alg>sum_baj) {
        cout <<"Algosia" << endl;
        return 0;
    }
    if(sum_alg<sum_baj) {
        cout <<"Bajtek" << endl;
        return 0;
    }

    sort(&alg[0],&alg[18], greater<int>());
    sort(&baj[0],&baj[18], greater<int>());

    for(long i=0;i<18;i++){
	    if(alg[i]>baj[i]) {
            cout <<"Algosia" << endl;
            return 0;
        }
        if(alg[i]< baj[i]) {
            cout <<"Bajtek" << endl;
            return 0;
        }
    }
    cout <<"remis" << endl;
    return 0;
 
}