Spend and Save
Easy · rating 950 · math
A store runs a promotion: spend at least 1000 cents and get a flat 100 cents off. Read the cart total in cents and print the amount the customer pays after any discount.
Editorial
Spend and Save applies a flat discount once the cart total reaches a threshold: spend at least 1000 cents to take 100 cents off. A single conditional handles it.
print(total - 100 if total >= 1000 else total)Complexity
Time: O(1). Space: O(1).