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
103
104
105
106
107
108
#include <iostream>
#include <map>
#include <vector>

struct ParticipantStatistics
{
    short Points = 0;
    std::map<short, short> NumberOfSpecificScore;
};

std::vector<short> ReadResults()
{
    auto participantResults = std::vector<short>();

    for (int i = 0; i < 18; ++i)
    {
        auto singleParticipantResult = 0;
        std::cin >> singleParticipantResult;
        participantResults.push_back(singleParticipantResult);
    }

    return participantResults;
}

ParticipantStatistics GetParticipantStatistics(const std::vector<short>& participantResults)
{
    ParticipantStatistics participantStatistics;

    for (const auto& singleParticipantResult : participantResults)
    {
        participantStatistics.Points += singleParticipantResult;
        participantStatistics.NumberOfSpecificScore[singleParticipantResult]++;
    }

    return participantStatistics;
}

void ShowStatistics(const ParticipantStatistics& participantStatistics)
{
    std::cout << "Points: " << participantStatistics.Points << std::endl;

    for (const auto& participantNumberOfSpecificScore : participantStatistics.NumberOfSpecificScore)
    {
        std::cout << participantNumberOfSpecificScore.first << ": " << participantNumberOfSpecificScore.second << std::endl;
    }
}

int main()
{
    const auto algosiaResults = ReadResults();
    const auto bajtekResults = ReadResults();
        
    const auto algosiaStatistics = GetParticipantStatistics(algosiaResults);
    const auto bajtekStatistics = GetParticipantStatistics(bajtekResults);

    //ShowStatistics(algosiaStatistics);
    //ShowStatistics(bajtekStatistics);

    if (algosiaStatistics.Points > bajtekStatistics.Points)
    {
        std::cout << "Algosia";
    }
    else if (algosiaStatistics.Points < bajtekStatistics.Points)
    {
        std::cout << "Bajtek";
    }
    else
    {        
        for (int i = 10; i >= 0; --i)
        {
            auto itAlgosiaStatistics = algosiaStatistics.NumberOfSpecificScore.find(i);
            auto itBajtekStatistics = bajtekStatistics.NumberOfSpecificScore.find(i);

            auto algosiaItExists = itAlgosiaStatistics != algosiaStatistics.NumberOfSpecificScore.end();
            auto bajtekItExists = itBajtekStatistics!= bajtekStatistics.NumberOfSpecificScore.end();

            if (algosiaItExists && bajtekItExists)
            {
                if (itAlgosiaStatistics->second > itBajtekStatistics->second)
                {
                    std::cout << "Algosia";
                    return 0;
                }
                else if (itAlgosiaStatistics->second < itBajtekStatistics->second)
                {
                    std::cout << "Bajtek";
                    return 0;
                }
            }
            else
            {
                if (algosiaItExists && !bajtekItExists)
                {
                    std::cout << "Algosia";
                    return 0;
                }
                else if (!algosiaItExists && bajtekItExists)
                {
                    std::cout << "Bajtek";
                    return 0;
                }
            }
        }
        std::cout << "remis";
    }

    return 0;
}