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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <iostream>
using namespace std;
int main() {
    int algosia[18];
    int bajtek[18];
    int sum_algosia = 0;
    int sum_bajtek = 0;
    int algosia_10 = 0;
    int bajtek_10 = 0;
    int max_points = 10;

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

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

    for (int i = 0; i < 18; i++) {
        sum_algosia += algosia[i];
        sum_bajtek += bajtek[i];

        if (algosia[i] == max_points) {
            algosia_10++;
        }

        if (bajtek[i] == max_points) {
            bajtek_10++;
        }
    }

    if (sum_algosia > sum_bajtek) {
        cout << "Algosia" << endl;
    } else if (sum_bajtek > sum_algosia) {
        cout << "Bajtek" << endl;
    } else if (sum_algosia == sum_bajtek) {
        if (algosia_10 == bajtek_10) {
            int i = max_points - 1;
            while(i > 0 && algosia_10 == bajtek_10) {
                int algosia_points = 0;
                int bajtek_points = 0;
                for (int j = 0; j < 18; j++) {
                    if (algosia[j] == i) {
                        algosia_points++;
                    }
                    if (bajtek[j] == i) {
                        bajtek_points++;
                    }
                }
                if (algosia_points > bajtek_points) {
                    cout << "Algosia" << endl;
                    return 0;
                } else if (bajtek_points > algosia_points) {
                    cout << "Bajtek" << endl;
                    return 0;
                }
                i--;
            }
            cout << "remis" << endl;
        } else if (bajtek_10 > algosia_10) {
            cout << "Bajtek" << endl;
        } else if (algosia_10 > bajtek_10) {
            cout << "Algosia" << endl;
        }

    }

    return 0;
}