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
#include <iostream>
#include <algorithm>
using namespace std;
int a[18];
int b[18];
int suma_a, suma_b,al=0,ba=0;
int main()
{
    for (int i=0;i<18;i++)
    {
        cin>>a[i];
    }
    for (int i=0;i<18;i++)
    {
        cin>>b[i];
    }
    sort(a,a+17);
    sort(b,b+17);
    for (int i=0;i<18;i++)
    {
        suma_a=suma_a+a[i];
    }
    for (int i=0;i<18;i++)
    {
        suma_b=suma_b+b[i];
    }
    if (suma_a>suma_b)
        cout<<"Algosia";
    else if (suma_a<suma_b)
        cout<<"Bajtek";
    else if (suma_a=suma_b)
    for (int i=17;i>=0;i--)
     if (a[i]>b[i])
           {al=a[i];
            break;}
        for (int i=17;i>=0;i--)
        if (b[i]>a[i])
            {ba=b[i];
            break;}
    if (al>ba&&suma_a==suma_b)
        cout<<"Algosia";
    else if (ba>al&&suma_a==suma_b)
        cout<<"Bajtek";
    else if (ba==al&&suma_a==suma_b)
        cout<<"remis"; 
    return 0;
}