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

using namespace std;

void solve() {
    int n = 18;
    int k = 10;

    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }

    int algosiaTotal = std::reduce(a.begin(), a.end());

    int bajtekTotal = std::reduce(b.begin(), b.end());

    if (algosiaTotal > bajtekTotal) {
        cout << "Algosia\n";
        return;
    } else if (algosiaTotal < bajtekTotal) {
        cout << "Bajtek\n";
        return;
    }

    unordered_map<int, int> algosiaCountByScore;
    for (int i = 0; i < n; i++) {
        algosiaCountByScore[a[i]] += 1;
    }

    unordered_map<int, int> bajtekCountByScore;
    for (int i = 0; i < n; i++) {
        // if the key does not exist yet, it will be created with value 0
        bajtekCountByScore[b[i]] += 1;
    }

    for (int score = k; score >= 1; score--) {
        // if the key does not exist yet, it will be created with value 0
        if (algosiaCountByScore[score] > bajtekCountByScore[score]) {
            cout << "Algosia\n";
            return;
        } else if (algosiaCountByScore[score] < bajtekCountByScore[score]) {
            cout << "Bajtek\n";
            return;
        }
    }

    cout << "remis\n";

    return;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
  
    return 0;
}