Advertisement
LusienGG

[C#] Game Of Names

Jun 11th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. class GameOfNames
  8. {
  9.     static void Main()
  10.     {
  11.         int n = int.Parse(Console.ReadLine());
  12.         var tempName = "";
  13.         long maxSum = long.MinValue;
  14.         for (int i = 0; i < n; i++)
  15.         {
  16.             string name = Console.ReadLine();
  17.             long points = long.Parse(Console.ReadLine());
  18.             for (int j = 0; j < name.Length; j++)
  19.             {
  20.                 if ((int)name[j] % 2 == 0)
  21.                 {
  22.                     points += (int)name[j];
  23.                 }
  24.                 else
  25.                 {
  26.                     points -= (int)name[j];
  27.                 }
  28.                
  29.             }
  30.             if (maxSum < points)
  31.             {
  32.                 tempName = name;
  33.                 maxSum = points;
  34.  
  35.             }
  36.         }
  37.         Console.WriteLine("The winner is {0} - {1} points", tempName, maxSum);
  38.  
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement