Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace fundamental
- {
- class MainClass
- {
- public static void Main()
- {
- List<int> listOne = Console.ReadLine().Split().Select(int.Parse).ToList();
- List<int> listTwo = Console.ReadLine().Split().Select(int.Parse).ToList();
- while(listOne.Count != 0 && listTwo.Count != 0)
- {
- int count = 0;
- if (listOne.Count <= listTwo.Count)
- {
- count = listOne.Count;
- }
- else
- {
- count = listTwo.Count;
- }
- //Console.WriteLine(count);
- for (int i = 0; i < count; i++)
- {
- int current = 0;
- int current1 = 0;
- if (listOne[i] < listTwo[i])
- {
- current = listOne[i];
- current1 = listTwo[i];
- listOne.RemoveAt(i);
- listTwo.RemoveAt(i);
- listTwo.Add(current1);
- listTwo.Add(current);
- break;
- }
- else if (listOne[i] > listTwo[i])
- {
- current = listOne[i];
- current1 = listTwo[i];
- listOne.RemoveAt(i);
- listTwo.RemoveAt(i);
- listOne.Add(current);
- listOne.Add(current1);
- break;
- }
- else if (listOne[i] == listTwo[i])
- {
- listOne.RemoveAt(i);
- listTwo.RemoveAt(i);
- break;
- }
- }
- }
- if(listOne.Count > 0)
- {
- Console.WriteLine($"First player wins! Sum: {listOne.Sum()}");
- }
- else
- {
- Console.WriteLine($"Second player wins! Sum: {listTwo.Sum()}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement