알고리즘

[알고리즘] 백준 12790 - Mini Fantasy War (C++)

blueberrysoda 2024. 12. 21. 23:52

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

#include <iostream>
using namespace std;

int Arr[8];

int main(){
    int T;
    cin >> T;

    for(int j=0; j<T; j++){
        for(int i=0; i<8; i++){
            cin >> Arr[i];
        }
        Arr[0] += Arr[4];
        Arr[1] += Arr[5];
        Arr[2] += Arr[6];
        Arr[3] += Arr[7];

        Arr[0] < 1 ? Arr[0] = 1 : 0;
        Arr[1] < 1 ? Arr[1] = 1 : 0;
        Arr[2] < 0 ? Arr[2] = 0 : 0;

        cout << Arr[0] * 1 + Arr[1] * 5 + Arr[2] * 2 + Arr[3] * 2 << "\n";
    }
    return 0;
}