Къде ми е грешката в тази задача и защо judge ми дава 0 точки?
Това е моя код.
https://pastebin.com/F4Raq3Ww
Ето и условието на задачата.
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 |
|
Благодаря много.