#include <iostream>
#include <vector>
using namespace std;
struct Player {
enum {
P_MAX = 10,
T_CNT = 18
};
char const *const name;
vector< int > count;
Player(char const *name) : name(name), count(1 + P_MAX + 1, 0) {
int &sum = count[P_MAX + 1];
for (int i = 0; i < T_CNT; ++i) {
int v;
cin >> v;
sum += v;
++count[v];
}
}
};
char const *solution(Player const &a, Player const &b) {
for (int i = Player::P_MAX + 1; i >= 0; --i) {
if (a.count[i] > b.count[i])
return a.name;
if (a.count[i] < b.count[i])
return b.name;
}
return "remis";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Player a("Algosia"), b("Bajtek");
cout << solution(a, b) << '\n';
}
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 | #include <iostream> #include <vector> using namespace std; struct Player { enum { P_MAX = 10, T_CNT = 18 }; char const *const name; vector< int > count; Player(char const *name) : name(name), count(1 + P_MAX + 1, 0) { int &sum = count[P_MAX + 1]; for (int i = 0; i < T_CNT; ++i) { int v; cin >> v; sum += v; ++count[v]; } } }; char const *solution(Player const &a, Player const &b) { for (int i = Player::P_MAX + 1; i >= 0; --i) { if (a.count[i] > b.count[i]) return a.name; if (a.count[i] < b.count[i]) return b.name; } return "remis"; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); Player a("Algosia"), b("Bajtek"); cout << solution(a, b) << '\n'; } |
English