#include <iostream>
#include <sstream>
#include <vector>
#include <string>
using namespace std;
typedef vector<int> vi;
struct userInfo
{
vi pointsForProblem;
int sum;
vector<int> numForPoints;
userInfo(string data) {
stringstream ss;
ss << data;
int v;
numForPoints.assign(11, 0);
pointsForProblem.reserve(18);
sum = 0;
while (ss >> v)
{
pointsForProblem.push_back(v);
sum += v;
numForPoints[v]++;
}
}
};
int compareTo(const userInfo &u1, const userInfo &u2)
{
if (u1.sum != u2.sum)
return u1.sum - u2.sum;
for (int p = 10; p > 0; p--)
if (u1.numForPoints[p] != u2.numForPoints[p])
return u1.numForPoints[p] - u2.numForPoints[p];
return 0;
}
int main(int argc, char* argv[])
{
string s;
getline(cin, s);
userInfo infoAlgosia(s);
getline(cin, s);
userInfo infoBajtek(s);
int cmp = compareTo(infoAlgosia, infoBajtek);
if (cmp > 0)
cout << "Algosia\n";
else if (cmp < 0)
cout << "Bajtek\n";
else
cout << "remis\n";
return 0;
}
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 | #include <iostream> #include <sstream> #include <vector> #include <string> using namespace std; typedef vector<int> vi; struct userInfo { vi pointsForProblem; int sum; vector<int> numForPoints; userInfo(string data) { stringstream ss; ss << data; int v; numForPoints.assign(11, 0); pointsForProblem.reserve(18); sum = 0; while (ss >> v) { pointsForProblem.push_back(v); sum += v; numForPoints[v]++; } } }; int compareTo(const userInfo &u1, const userInfo &u2) { if (u1.sum != u2.sum) return u1.sum - u2.sum; for (int p = 10; p > 0; p--) if (u1.numForPoints[p] != u2.numForPoints[p]) return u1.numForPoints[p] - u2.numForPoints[p]; return 0; } int main(int argc, char* argv[]) { string s; getline(cin, s); userInfo infoAlgosia(s); getline(cin, s); userInfo infoBajtek(s); int cmp = compareTo(infoAlgosia, infoBajtek); if (cmp > 0) cout << "Algosia\n"; else if (cmp < 0) cout << "Bajtek\n"; else cout << "remis\n"; return 0; } |
English