ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2023. Donald is a postman

С# Solution
Posted by zak427 29 Jun 2016 14:31
using System;

namespace Csharp_2023
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int num = 1;
            int sum = 0;

            for (int z = 1; z <= n; z++)
            {
                string str1 = Console.ReadLine();

                for (int f = 1; f <= n; f++)
                {
                    if (str1[0] == 'A' || str1[0] == 'P' || str1[0] == 'O' || str1[0] == 'R')
                    {
                        if (num == 1) sum += 0;
                        else if (num == 2) sum += 1;
                        else if (num == 3) sum += 2;
                        num = 1;
                        break;
                    }
                    else if (str1[0] == 'B' || str1[0] == 'M' || str1[0] == 'S')
                    {
                        if (num == 1) sum += 1;
                        else if (num == 2) sum += 0;
                        else if (num == 3) sum += 1;
                        num = 2;
                        break;
                    }
                    else if (str1[0] == 'D' || str1[0] == 'G' || str1[0] == 'J' || str1[0] == 'K' || str1[0] == 'T' || str1[0] == 'W')
                    {
                        if (num == 1) sum += 2;
                        else if (num == 2) sum += 1;
                        else if (num == 3) sum += 0;
                        num = 3;
                        break;
                    }
                }
            }
         Console.WriteLine(sum);
        }
    }
}