Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _01._Vapor_Winter_Sale
- {
- class GameWithDLC
- {
- public string GameName { get; set; }
- public string DLC { get; set; }
- public decimal Price { get; set; }
- }
- class Program
- {
- static void Main()
- {
- var input = Console.ReadLine().Split(", ");
- var games = new Dictionary<string, decimal>();
- var gamesWithDLC = new List<GameWithDLC>();
- for (int i = 0; i < input.Length; i++)
- {
- var command = input[i];
- if (command.Contains("-"))
- {
- var data = command.Split("-");
- var gameName = data[0];
- var price = decimal.Parse(data[1]);
- games[gameName] = price;
- }
- else if (command.Contains(":"))
- {
- var data = command.Split(":");
- var gameName = data[0];
- var DLC = data[1];
- if (games.ContainsKey(gameName))
- {
- var price = games[gameName] * 1.2m * 0.5m;
- var game = new GameWithDLC();
- game.GameName = gameName;
- game.DLC = DLC;
- game.Price = price;
- gamesWithDLC.Add(game);
- games.Remove(gameName);
- }
- }
- }
- foreach (var game in gamesWithDLC.OrderBy(x => x.Price))
- {
- Console.WriteLine($"{game.GameName} - {game.DLC} - {game.Price:F2}");
- }
- foreach (var game in games.OrderByDescending(x => x.Value))
- {
- Console.WriteLine($"{game.Key} - {(game.Value * 0.8m):F2}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement