알고리즘

[알고리즘] 백준 2511 - 카드놀이 (C++)

blueberrysoda 2024. 9. 25. 23:25

[문제 링크] : https://www.acmicpc.net/problem/2511

#include <iostream>
using namespace std;
 
int A[10], B[10];
int cntA = 0, cntB = 0;
char C = 'D';
 
int main(){
    for(int i=0; i<10; i++){
        cin >> A[i];
    }
    for(int i=0; i<10; i++){
        cin >> B[i];
    }

    for(int i=0; i<10; i++){
        if(A[i] > B[i]){
            cntA += 3;
            C = 'A';
        }
        else if(A[i] < B[i]){
            cntB += 3;
            C = 'B';
        }
        else{
            cntA++;
            cntB++;
        }
    }

    cout << cntA << " " << cntB << "\n";

    if(cntA > cntB){
        cout << "A\n";
    }
    else if(cntA < cntB){
        cout << "B\n";
    }
    else{
        cout << C << "\n";
    }
    return 0;
}