Humidifier 1

ABC 383

Problem 33 of 50

Easy

What to do

A humidifier starts empty. Water is added at specific times (given as (time, volume) pairs). Between additions, water decreases by 1 unit per time unit (but never below 0). Calculate the water remaining after the last addition.

Key Concepts

variables loops basic math input/output

Examples

Input: n = 4, additions = [(1, 3), (3, 1), (4, 4), (7, 1)]

Output: 3

Input: n = 3, additions = [(1, 8), (10, 11), (21, 5)]

Output: 5

Tips for Beginners

  • Focus on understanding the logic, not memorizing syntax
  • Use print statements to debug your code
  • Don't worry about input parsing - the function handles that for you
  • If stuck, try writing out your solution on paper first

Python Editor

Loading Python...