Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApplication67
- {
- internal class Program
- {
- private static void Main(string[] args)
- {
- var budget = decimal.Parse(Console.ReadLine());
- var productPrice = new Dictionary<string, decimal>();
- var input = Console.ReadLine();
- while (input != "end")
- {
- var inputArgs = input.Split(' ');
- productPrice[inputArgs[0]] = decimal.Parse(inputArgs[1]);
- input = Console.ReadLine();
- }
- if (productPrice.Sum(x => x.Value) > budget)
- Console.WriteLine("Need more money... Just buy banichka");
- else
- foreach (var kvp in productPrice.OrderByDescending(x => x.Value).ThenBy(x => x.Key.Length))
- Console.WriteLine($"{kvp.Key} costs {kvp.Value:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement