Dsa
Dynamic Programming
Easy
Flower Planting
You are planting flowers in a garden where each flower type has a specific beauty score and occupies a fixed amount of space. Your garden has a limited area, and you want to maximize the total beauty score of the flowers you can plant. Given a list of flower types with their respective beauty scores and the space they occupy, calculate the maximum total beauty score you can achieve within the area limitation.
Input format:
- The first line contains two integers n (1 ≤ n ≤ 50) and a (1 ≤ a ≤ 1000), the number of flower types and the garden area.
- The second line contains n pairs of integers representing the beauty scores and the space occupied by each flower type.
Output format:
- Output a single integer, the maximum total beauty score.
Example:
Input:
3 5
10 1
5 2
15 3
Output:
25
Key concepts
dynamic_programminggreedyarray
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now