#include<bits/stdc++.h> using std::cin, std::cout; int cntA[10]; int cntB[10]; int sumA, sumB; int t; int win() { if(sumA > sumB) return 1; else if(sumB < sumA) return 0; for(int i = 9; i >= 0; --i) { if(cntA[i] == cntB[i]) continue; return cntA[i] > cntB[i]; } return 2; } int main() { cin.tie(0) -> sync_with_stdio(0); for(int i = 0; i < 18; ++i) { cin >> t; sumA += t; cntA[t]++; } for(int i = 0; i < 18; ++i) { cin >> t; sumB += t; cntB[t]++; } int x = win(); if(x == 1) cout << "Algosia"; else if(x == 0) cout << "Bajtek"; else cout << "remis"; }
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 | #include<bits/stdc++.h> using std::cin, std::cout; int cntA[10]; int cntB[10]; int sumA, sumB; int t; int win() { if(sumA > sumB) return 1; else if(sumB < sumA) return 0; for(int i = 9; i >= 0; --i) { if(cntA[i] == cntB[i]) continue; return cntA[i] > cntB[i]; } return 2; } int main() { cin.tie(0) -> sync_with_stdio(0); for(int i = 0; i < 18; ++i) { cin >> t; sumA += t; cntA[t]++; } for(int i = 0; i < 18; ++i) { cin >> t; sumB += t; cntB[t]++; } int x = win(); if(x == 1) cout << "Algosia"; else if(x == 0) cout << "Bajtek"; else cout << "remis"; } |