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

int main() {
    vector<int> algosia(18);
    vector<int> bajtek(18);

    for (int i = 0; i < 18; ++i) {
        cin >> algosia[i];
    }

    for (int i = 0; i < 18; ++i) {
        cin >> bajtek[i];
    }

    int algosiaScore = 0, bajtekScore = 0;
    int algosiaPerfect = 0, bajtekPerfect = 0;

     for (int i = 0; i < 18; ++i) {
        algosiaScore += algosia[i];
        bajtekScore += bajtek[i];
        if (algosia[i] == 10) algosiaPerfect++;
        if (bajtek[i] == 10) bajtekPerfect++;
    }


    if (algosiaScore > bajtekScore) {
        cout << "Algosia" << endl;
    } else if (algosiaScore < bajtekScore) {
        cout << "Bajtek" << endl;
    } else {
        if (algosiaPerfect > bajtekPerfect) {
            cout << "Algosia" << endl;
        } else if (algosiaPerfect < bajtekPerfect) {
            cout << "Bajtek" << endl;
        } else {
            for (int i = 9; i >= 0; --i) {
                int algosiaCount = 0, bajtekCount = 0;
                for (int j = 0; j < 18; ++j) {
                    if (algosia[j] == i) algosiaCount++;
                    if (bajtek[j] == i) bajtekCount++;
                }
                if (algosiaCount > bajtekCount) {
                    cout << "Algosia" << endl;
                    return 0;
                } else if (algosiaCount < bajtekCount) {
                    cout << "Bajtek" << endl;
                    return 0;
                }
            }
            cout << "remis" << endl;
        }
    }

    return 0;
}