Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

retterathtom avatar retterathtom 5 Точки

3. Legendary farming

Привет,

 

не зная защо ми гърми задачата в judge. Всеки вход от задачата ми излиза правилен. Ето го кодът: 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LegendaryFarming
{
    class Program
    {
        public static void Main()
        {
            Dictionary<string, int> keyMaterials = new Dictionary<string, int>();
            keyMaterials["motes"] = 0;
            keyMaterials.Add("fragments", 0);
            keyMaterials.Add("shards", 0);
            Dictionary<string, int> junkMaterials = new Dictionary<string, int>();

            while (true)
            {
                string[] input = Console.ReadLine()
                    .Split();

                bool hasToBreak = false;
                for (int i = 0; i < input.Length; i+= 2)
                {
                    int quantity = int.Parse(input[i]);
                    string material = input[i + 1].ToLower();
                    if (material == "shards" || material == "fragments" || material == "motes")
                    {
                        keyMaterials[material] += quantity;

                        if (keyMaterials[material] >= 250)
                        {
                            keyMaterials[material] -= 250;
                            if (material == "shard")
                            {
                                Console.WriteLine($"Shadowmourne obtained!");
                            }
                            else if (material == "fragments")
                            {
                                Console.WriteLine($"Valanyr obtained!");
                            }
                            else
                            {
                                Console.WriteLine($"Dragonwrath obtained!");
                            }
                            hasToBreak = true;
                            break;
                        }
                    }
                    else
                    {
                        if (junkMaterials.ContainsKey(material) == false)
                        {
                            junkMaterials[material] = 0;
                        }
                        junkMaterials[material] += quantity;

                    }
                }
                if (hasToBreak)
                {
                    break;
                }
            }
            Dictionary<string, int> filteredKeyMaterials = keyMaterials
                .OrderByDescending(kvp => kvp.Value)
                .ThenBy(kvp => kvp.Key)
                .ToDictionary(a => a.Key, a => a.Value);
            foreach (var kvp in filteredKeyMaterials)
            {
                string material = kvp.Key;
                int quantity = kvp.Value;
                Console.WriteLine($"{material}: {quantity}");
            }
            foreach (var kvp in junkMaterials.OrderBy(kvp => kvp.Key))
            {
                string material = kvp.Key;
                int quantity = kvp.Value;
                Console.WriteLine($"{material}: {quantity}");
            }
        }
    }
}

 

Ако някой може да ми каже къде е грешката и защо ми дава 60 от 100 точки, ще е супер.

Тагове:
0
Fundamentals Module 07/11/2018 09:47:51
TeodorStefanovPld avatar TeodorStefanovPld 1274 Точки

пусни и условието,че не ги помним на изуст условията и какво се иска. И  друг път слагай кода в pastebin/или неговите алтернативи, по-лесен е за четене от там.

0
retterathtom avatar retterathtom 5 Точки

You’ve beaten all the content and the last thing left to accomplish is own a legendary item. However, it’s a tedious process and requires quite a bit of farming. Anyway, you are not too pretentious – any legendary will do. The possible items are:

  • Shadowmourne – requires 250 Shards;
  • Valanyr – requires 250 Fragments;
  • Dragonwrath – requires 250 Motes;

Shards, Fragments and Motes are the key materials, all else is junk. You will be given lines of input, such as
2 motes 3 ores 15 stones. Keep track of the key materials - the first that reaches the 250 mark wins the race. At that point, print the corresponding legendary obtained. Then, print the remaining shards, fragments, motes, ordered by quantity in descending order, then by name in ascending order, each on a new line. Finally, print the collected junk items, in alphabetical order.

Input

  • Each line of input is in format {quantity} {material} {quantity} {material} … {quantity} {material}

Output

  • On the first line, print the obtained item in format {Legendary item} obtained!
  • On the next three lines, print the remaining key materials in descending order by quantity
    • If two key materials have the same quantity, print them in alphabetical order
  • On the final several lines, print the junk items in alphabetical order
    • All materials are printed in format {material}: {quantity}
    • All output should be lowercase, except the first letter of the legendary

Examples

Input

Output

3 Motes 5 stones 5 Shards

6 leathers 255 fragments 7 Shards

Valanyr obtained!

fragments: 5

shards: 5

motes: 3

leathers: 6

stones: 5

123 silver 6 shards 8 shards 5 motes

9 fangs 75 motes 103 MOTES 8 Shards

86 Motes 7 stones 19 silver

Dragonwrath obtained!

shards: 22

motes: 19

fragments: 0

fangs: 9

silver: 123

0
TeodorStefanovPld avatar TeodorStefanovPld 1274 Точки

няма да повярваш каква е грешката ти

   if (material == "shard") това трябва да е shards ! :D

motes fragments ги хващаш но в shard не влизаш защото ти подават shards

1
07/11/2018 12:35:41
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.