Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Santa_sPresentFactory
- {
- class Program
- {
- static void Main(string[] args)
- {
- Stack<int> box = new Stack<int>( Console.ReadLine().Split().Select(int.Parse).ToArray());
- Queue<int> magic = new Queue<int>(Console.ReadLine().Split().Select(int.Parse).ToArray());
- Dictionary<string, Dictionary<int, int>> presents = new Dictionary<string, Dictionary<int, int>> {
- {"Doll", new Dictionary<int, int>{{ 150,0} } } ,
- {"Wooden train", new Dictionary<int, int>{ { 250,0} } },
- {"Teddy bear", new Dictionary<int, int>{ { 300,0} } },
- { "Bicycle", new Dictionary<int, int>{{ 400,0} } } ,
- };
- while(box.Count>0&& magic.Count>0)
- {
- //box.Pop* //magic.Dequeue
- int currentBox = box.Peek();
- int currentMagic = magic.Peek();
- if (currentBox==0)
- {
- box.Pop();
- continue;
- }
- if(currentMagic==0)
- {
- magic.Dequeue();
- continue;
- }
- int sum = currentBox * currentMagic;
- if (sum < 0)
- {
- box.Pop();
- magic.Dequeue();
- box.Push(sum);
- sum = 0;
- }
- sum = currentBox * currentMagic;
- if ( sum>0)
- {
- foreach (var item in presents)
- {
- foreach (var toy in item.Value)
- {
- if (!item.Value.ContainsKey(sum))
- {
- magic.Dequeue();
- box.Push(currentBox + 15);
- }
- else
- {
- magic.Dequeue();
- box.Pop();
- //увеличавам броя на подаръците
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement