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 Program
- {
- static void Main(string[] args)
- {
- var input = Console.ReadLine().Split(", ");
- Dictionary<string, double> games = new Dictionary<string, double>();
- Dictionary<string, string> contentToGame = new Dictionary<string, string>();
- for (int i = 0; i < input.Length; i++)
- {
- if (input[i].Contains('-'))
- {
- string[] splitToString = input[i].Split('-');
- string game = splitToString[0];
- double price = double.Parse(splitToString[1]);
- if (!games.ContainsKey(game))
- {
- games[game] = price;
- }
- }
- else if (input[i].Contains(':'))
- {
- string[] splitToString = input[i].Split(':');
- string game = splitToString[0];
- string dlc = splitToString[1];
- if (games.ContainsKey(game))
- {
- contentToGame[game] = dlc;
- }
- }
- }
- foreach (var game in games.OrderBy(x => x.Value))
- {
- foreach (var dlc in contentToGame)
- {
- if (game.Key == dlc.Key)
- {
- double sum = game.Value;
- double gameSum = sum + sum * 0.20;
- gameSum -= gameSum * 0.50;
- Console.WriteLine($"{game.Key} - {dlc.Value} - {gameSum:F2}");
- games.Remove(game.Key);
- }
- }
- }
- foreach (var dlc in contentToGame)
- {
- foreach (var game in games.OrderByDescending(x => x.Value))
- {
- if (!game.Key.Contains(dlc.Key))
- {
- double gamePrice = game.Value * 0.80;
- Console.WriteLine($"{game.Key} - {gamePrice:F2}");
- games.Remove(game.Key);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement