21. Electricity Bill
Core1000 ms256 MBSolved by 0%
An electricity board charges by slab:
| Units | Rate per unit | | --- | --- | | First 100 | 5 | | Next 100 (101–200) | 8 | | Next 300 (201–500) | 12 | | Above 500 | 20 |
Rates apply per slab, not to the whole bill. Someone using 150 units pays
100 × 5 + 50 × 8, not 150 × 8.
Read the number of units and print the total bill.
Constraints - `0 ≤ units ≤ 1000000`
Input
A single line containing one integer n.
Output
Print one integer, the total bill.
Input50
Output250
Notestays inside the first slab
Input150
Output900
Notecrosses into the second slab, where charging the whole amount at one rate gives 1200 instead
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.
Hint 1Where to start
Hint 2The approachOpen hint 1 first. This one carries on from it.
Hint 3PseudocodeOpen hint 2 first. This one carries on from it.
Hint 4Full solutionOpen hint 3 first. This one carries on from it.