Editorial for DMOPC '15 Contest 2 P2 - Admin War


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

by cheesecake

Simple implementation problem. Store card values in arrays, then iterate through both while keeping track of the score. Output the score and outcome as required.

#include <bits/stdc++.h>
using namespace std;

int N, X[201], F[201], x, f;;
int main()
{
    scanf("%d",&N);
    for (int i = 0; i < N; ++i)
        scanf("%d",&X[i]);
    for (int i = 0; i < N; ++i)
        scanf("%d",&F[i]);
    for (int i = 0; i < N; ++i)
    {
        if (X[i] > F[i])
            x++;
        else if (F[i] > X[i])
            f++;
    }
    printf("%d %d\n",x,f);
    if (x > f)
        printf("Xyene\n");
    else if (f > x)
        printf("FatalEagle\n");
    else
        printf("Tie\n");
    return 0;
}

Time Complexity: \mathcal{O}(N)


Comments

There are no comments at the moment.