Sponsored
Use these hints if you're stuck. Try solving on your own first.
Use brute force: For the ith item in the shop with a loop find the first position j satisfying the conditions and apply the discount, otherwise, the discount is 0.
Solve with full IDE support and test cases