Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace zadacha
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] stack = Console.ReadLine().Split(", ").Select(int.Parse).ToArray();
- int[] queue = Console.ReadLine().Split(", ").Select(int.Parse).ToArray();
- Stack<int> lilies = new Stack<int>(stack);
- Queue<int> roses = new Queue<int>(queue);
- List<int> storage = new List<int>();
- int count = 0;
- int wreath = 0;
- while (lilies.Any() && roses.Any())
- {
- if (lilies.Peek() + roses.Peek() == 15)
- {
- count++;
- lilies.Pop();
- roses.Dequeue();
- }
- else if (lilies.Peek() + roses.Peek() > 15)
- {
- lilies.Push(lilies.Pop() - 2);
- }
- else
- {
- storage.Add(lilies.Pop());
- storage.Add(roses.Dequeue());
- }
- }
- if (storage.Count > 0)
- {
- if (storage.Sum() > 15)
- {
- wreath = storage.Sum() / 15;
- count += wreath;
- }
- }
- if (count >= 5)
- {
- Console.WriteLine($"You made it, you are going to the competition with {count} wreaths!");
- }
- else
- {
- Console.WriteLine($"You didn't make it, you need {5-count} wreaths more!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement