#include <algorithm> #include <bits/stdc++.h> #include <vector> using namespace std; int main(){ vector<int> a(18), b(18); int sum_a, sum_b; sum_a = sum_b = 0; for(int i=0; i<18; i++){ cin >> a[i]; sum_a += a[i]; } for(int i=0; i<18; i++){ cin >> b[i]; sum_b += b[i]; } int win = 0; if(sum_a > sum_b){ win = 1; } else if(sum_a < sum_b){ win = 2; } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); int i = 0; while(win == 0 && i < 18){ if(a[i] > b[i]) win = 1; if(a[i] < b[i]) win = 2; i++; } if(win == 0){ cout<<"remis"<<endl; } if(win == 1){ cout<<"Algosia"<<endl; } if(win == 2){ cout<<"Bajtek"<<endl; } }
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 | #include <algorithm> #include <bits/stdc++.h> #include <vector> using namespace std; int main(){ vector<int> a(18), b(18); int sum_a, sum_b; sum_a = sum_b = 0; for(int i=0; i<18; i++){ cin >> a[i]; sum_a += a[i]; } for(int i=0; i<18; i++){ cin >> b[i]; sum_b += b[i]; } int win = 0; if(sum_a > sum_b){ win = 1; } else if(sum_a < sum_b){ win = 2; } sort(a.rbegin(), a.rend()); sort(b.rbegin(), b.rend()); int i = 0; while(win == 0 && i < 18){ if(a[i] > b[i]) win = 1; if(a[i] < b[i]) win = 2; i++; } if(win == 0){ cout<<"remis"<<endl; } if(win == 1){ cout<<"Algosia"<<endl; } if(win == 2){ cout<<"Bajtek"<<endl; } } |