02. On the Way to Annapurna Може ли малко помощ
Здравейте, малко помощ, judge ми дава 30/100
моето решение : https://pastebin.com/uqAfNkGe
задача условие: https://judge.softuni.bg/Contests/Practice/Index/1516#1
Здравейте, малко помощ, judge ми дава 30/100
моето решение : https://pastebin.com/uqAfNkGe
задача условие: https://judge.softuni.bg/Contests/Practice/Index/1516#1
using System;
using System.Collections.Generic;
using System.Linq;
namespace ConsoleApp12
{
class Program
{
static void Main(string[] args)
{
Dictionary<string, List<string>> dict = new Dictionary<string, List<string>>();
string command;
while ((command = Console.ReadLine()) != "END")
{
string[] split = command.Split("->").ToArray();
string storeName = split[1];
//if (command.Contains("Remove"))
if (split[0].Contains("Remove"))
{
if (dict.ContainsKey(storeName))
{
dict.Remove(storeName);
}
}
//if (command.Contains("Add"))
if (split[0].Contains("Add"))
{
var items = split[2].Split(",").ToList();
if(!dict.ContainsKey(storeName))
{
dict.Add(storeName, new List<string>());
}
for (int i = 0; i < items.Count; i++)
{
dict[storeName].Add(items[i]);
}
}
}
Console.WriteLine("Stores list:");
foreach (var (storeName, items) in dict.OrderByDescending(x => x.Value.Count).ThenByDescending(x => x.Key))
{
Console.WriteLine($"{storeName}");
foreach (var item in items)
{
Console.WriteLine($"<<{item}>>");
}
}
}
}
}
Мерси!