+ Нов въпрос
Selda -1 Точки

## Задача 6. Heists - more exercises array

Здравейте, това е решението което успях да измисля https://pastebin.com/1ETXYNFA, примерните тестове от условието минават, но Judge ми дава 66/100. Условието на задачата е:

You are the main accountant for a group of bandits, whose main line of work is robbing banks and stores. Your job is to calculate the score from the heist, calculating the price of the loot and taking the expenses into account.

On the first line, you will receive an array with two elements. The first element represents the price of the jewels and the second – the price of the gold.

On each of the next lines, you will receive input in the format “{loot} {heist expenses}” until you receive the command “Jail Time”. The loot will be a string containing random characters. The jewels will be represented with the character “%” and the gold – with the character “\$”. If you find either from the symbols it means you have found one of the goodies.

Upon receiving “Jail Time you have to calculate the total earnings and the total expenses from the heists. If the total earnings are more or equal to the total expenses print: “Heists will continue. Total earnings: {money earned}.”. Otherwise print: “Have to find another job. Lost: {money lost}.”.

Examples

 Input Output Comments 10 20 ASDA% 50 DaS@!%\$\$ 10 \$\$ 10 Jail Time Heists will continue. Total earnings: 30. We have price of the jewels of 10 and price of the gold of 20. In the first heist, we found one jewel (total earnings of 10), but the expenses are 50. 2nd heist -> 2 gold and 1 jewel -> total earnings = 50 + 10 (from the previous heist) and expenses of 10 + 50 (from previous heist) 3rd heist -> 2 gold -> total earnings = 100; total expenses: 10 + 60 = 70. Total: 100 (total earnings) – 70 (total expenses) = 30

 Input Output 2000 10000 ASDAs 500000 %ASD\$ 1000000 \$S\$&*_ASD 1000 AF#^&*LP 20000 \$ 100000000 Jail Time Have to find another job. Lost: 101479000.

Тагове:
0

Сложи едно равно на if (totalIncome > totalCost) тоест totalIncome трябва да е по-голямо или равно >= и ще мине 100/100.

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

В случая ясно е написано в условието: If the total earnings are more or equal to the total expenses print blabla

0
22/02/2018 22:31:01
Selda -1 Точки

Благодаря! :)

0