Candy Button
ABC 376Problem 40 of 50
EasyWhat to do
A button is pressed at times given in list `t`. A candy is dispensed only if at least `c` seconds have passed since the last candy was given (first press always gives a candy). Count the total candies received.
Key Concepts
if-statements
loops
basic math
input/output handling
Examples
Input:
n = 6, c = 5, t = [1, 3, 7, 8, 10, 12]
Output:
3
Input:
n = 3, c = 2, t = [0, 2, 4]
Output:
3
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...