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
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
#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 algosia_score = 0;
    int bajtek_score = 0;


    for (int i = 0; i < 18; ++i) 
    {
        algosia_score += algosia[i];
        bajtek_score += bajtek[i];
    }


    if (algosia_score > bajtek_score) 
    {
        cout << "Algosia" << endl;
    } 
    else if (bajtek_score > algosia_score) 
    {
        cout << "Bajtek" << endl;
    } 
    else 
    {

        int algosia_max = 0;
        int bajtek_max = 0;
        for (int i = 0; i < 18; ++i) 
        {
            if (algosia[i] == 10) 
            {
                algosia_max++;
            }
            if (bajtek[i] == 10) 
            {
                bajtek_max++;
            }
        }


        if (algosia_max > bajtek_max) 
        {
            cout << "Algosia" << endl;
        } 
        else if (bajtek_max > algosia_max) 
        {
            cout << "Bajtek" << endl;
        } 
        else 
        {

            for (int i = 9; i >= 0; --i) 
            {
                int algosia_count = 0;
                int bajtek_count = 0;
                for (int j = 0; j < 18; ++j) 
                {
                    if (algosia[j] == i) 
                    {
                        algosia_count++;
                    }
                    if (bajtek[j] == i) 
                    {
                        bajtek_count++;
                    }
                }
                if (algosia_count > bajtek_count) 
                {
                    cout << "Algosia" << endl;
                    return 0;
                } 
                else if (bajtek_count > algosia_count) 
                {
                    cout << "Bajtek" << endl;
                    return 0;
                }
            }

            cout << "remis" << endl;
        }
    }

    return 0;
}