Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Text;
- public class Program
- {
- public static void Main()
- {
- string[] input = Console.ReadLine().Split(", ");
- Dictionary<string,double> gamePrice = new Dictionary<string,double>();
- Dictionary <string,string> gameDlc = new Dictionary <string,string>();
- foreach (string game in input)
- {
- if (!game.Contains(":"))
- {
- string[] tokens = game.Split("-");
- string gameName = tokens[0];
- double price = double.Parse(tokens[1]);
- gamePrice.Add(gameName,price);
- }
- else
- {
- string[] tokens = game.Split(":");
- string gameName = tokens[0];
- string dlc = tokens[1];
- if (gamePrice.ContainsKey(gameName))
- {
- gameDlc.Add(gameName,dlc);
- gamePrice[gameName]*=1.20;
- }
- }
- }
- foreach (var currGame in gameDlc)
- {
- if (gamePrice.ContainsKey(currGame.Key))
- {
- gamePrice[currGame.Key]*=0.50;
- }
- }
- foreach (var kvp in gamePrice.OrderBy(x=>x.Value))
- {
- string game = kvp.Key;
- double price = kvp.Value;
- if (gameDlc.ContainsKey(game))
- {
- string dlc = gameDlc[game];
- Console.WriteLine("{0} - {1} - {2:f2}",game,dlc,price);
- }
- }
- Dictionary<string,double> noDlcGamePrice = new Dictionary<string,double>();
- foreach (var kvp in gamePrice)
- {
- string game = kvp.Key;
- double price = kvp.Value;
- if (gameDlc.ContainsKey(game)==false)
- {
- noDlcGamePrice.Add(game,price);
- }
- }
- foreach (var kvp in noDlcGamePrice.OrderByDescending(x=>x.Value))
- {
- Console.WriteLine("{0} - {1:f2}",kvp.Key,kvp.Value*0.8);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement