Coki's Products


Submit solution


Points:100 (partial)
Time limit:1.5s
Memory limit:128M
Author:

Tags
Arrays
Difficulty
Intermediate

Coki is a very bright boy! He likes numbers a lot, but most of the time he is pretty confused by them.

One day, Coki decided he wanted to be a shopping boy, i.e. a boy who gets lists of products from people, buys the products, and delivers them. Unfortunately for him, the owner of the supermarket was his evil-genius twin Koci, who always cheats Coki and makes him sad. Also, Coki loves numbers, but cannot use them...

Help Coki not to be cheated by Koci!

You are given N products with their prices. You are also given M lists of products. Your task is to write a program, which calculates the total sum for each list of products.

Input

You will receive an array of strings as the only parameter of the solve(args) function

  • Each array item will contain N, N products with prices, M and M lists of products
  • Note: see sample tests

Output

Print to the standard output, i.e. with console.log() method

  • For each list, print its total sum
    • With exactly 2 digits after the decimal point
      • use .toFixed(2) method

Constraints

  • 10 <= N < 218
  • 3 <= M < 221
  • Each list will have at most 210 products

Sample tests

Input

    const args = [
        "5",
        "milk 1.2",
        "orange juice 2.9",
        "icecream 2",
        "cake 5.1",
        "beer 1.2",
        "5",
        "2 beer, 3 orange juice",
        "milk, cake",
        "icecream, 2 cake",
        "icecream, icecream, 3 icecream",
        "5 orange juice, 3 orange juice, orange juice, orange juice"
    ];
    solve(args);

Output

    11.10
    6.30
    12.20
    10.00
    29.00

Comments


  • 0
    ivan.kirov
     commented on Nov. 4, 2018 edit 3

    Инпута, поне на python, си идва стандартно на отделни редове.


  • 0
    ghzlatarev
     commented on Sept. 9, 2018

    Качете времето за C# плс. Няма нито едно решение което да минава последния огромен тест.


  • 0
    nikolaivassilev
     commented on July 22, 2018

    Някой решавал ли е такъв тип задача, където input-а е в масив на C# Как четете input-а?


  • 0
    ghzlatarev
     commented on June 10, 2018

    Възможно ли е да се качат повече тест кейсове. Не разбирам защо не минавам повече от първите 5...


    • 2
      dyanakie
       commented on June 12, 2018

      Горе във about и после problems info, може да видиш всички тест кейсове.


  • 1
    stoyanoff.martin
     commented on May 28, 2018

    Времето тук е доста малко. Има само едно минало решение и то е на JS. Бихте ли го увеличили?