Counter Strike
Отново зацепих на задача от примерен изпит. Не мога да си открия защо ми гърми в judge, какво ли не сменям, работи си с примерните входове и изходи, обаче ми дава хиляда пъти 42/100. Ако някой може да помогне, тъй като аз вече идея нямам.Започвам да се чудя, аз ли нещо не виждам или не разбирам в условието, или просто трябва решението да ми е 1 към 1 с това в системата.
Сменям типове данни, дадени са по условие с int, но пробвам и с double, търся уловка и пак не мърда от 42/100:https://pastebin.com/zVE8PNaL
https://judge.softuni.bg/Contests/Practice/Index/2305#0
Programming Fundamentals Mid Exam Retake 07 April 2020
Problem 1. Counter Strike
Write a program that keeps track of every won battle against an enemy. You will receive initial energy. Afterwards you will start receiving the distance you need to go to reach an enemy until the "End of battle" command is given, or until you run out of energy.
The energy you need for reaching an enemy is equal to the distance you receive. Each time you reach an enemy, your energy is reduced. This is considered a successful battle (win). If you don't have enough energy to reach an the enemy, print:
"Not enough energy! Game ends with {count} won battles and {energy} energy"
and end the program.
Every third won battle increases your energy with the value of your current count of won battles.
Upon receiving the "End of battle" command, print the count of won battles in the following format:
"Won battles: {count}. Energy left: {energy}"
Input / Constraints
- On the first line you will receive initial energy – an integer [1-10000].
- On the next lines, you will be receiving distance of the enemy – an integer [1-10000]
Output
- The description contains the proper output messages for each case and the format in which they
should be print.
Examples
Input |
Output |
Comments |
100 10 10 10 1 2 3 73 10 |
Not enough energy! Game ends with 7 won battles and 0 energy |
Initial energy is 100. The first distance is 10, so we subtract 10 from 100 and we consider this a won battle. We are left with 90 energy. Next distance – 10, and 80 energy left. Next distance – 10, 3 won battles and 70 energy, but since we have 3 won battles, we increase the energy with the current count of won battle, in this case – 3 and it becomes 73. The last distance we receive – 10 is unreachalble since we have 0 energy, so we print the appropriate message and the program ends. |
200 54 14 28 13 End of battle |
Won battles: 4. Energy left: 94 |
|
Thank you very much!