#S0016. 生命值状态更新

生命值状态更新

1. Description

🎮 Game State Synchronization

In online games like Minecraft, servers handle real-time player status changes:

  • Health increases when getting a potion
  • Health decreases when attacked
  • Health must stay between 0-100

🛠️ Task

Implement a health update system. Process events until receiving end, then output final health.

Event Formats:

  • heal number
  • hurt number

2. Input & Output

Input:

  • Multiple lines of events
  • Last line is end

Output:

  • Final health (clamped between 0-100)

Example

# Input:  
heal 120  
hurt 50  
hurt 30  
end  

# Process:  
100 → 50 → 20  
# Output: 20  
# Input:  
hurt 15  
heal 10  
end  

# Process:  
-15 → 0  
# Output: 0