#P16818. [蓝桥杯 2026 国 Python B] 仓库管理
[蓝桥杯 2026 国 Python B] 仓库管理
Problem Description
Xiao Lan is a warehouse manager at a large logistics center. Today, the system issued an urgent task: all standard containers must be stored in the warehouse and assigned to shelves.
The shelves are numbered from left to right as . Because the distance for the automated robotic arm to deliver a container to different shelves varies, placing container onto shelf costs units of electricity.
The company requires that the total electricity cost of this storage task must lie within the closed interval . At the same time, to avoid any single shelf bearing too much weight, Xiao Lan wants the shelf that holds the most containers to hold as few as possible.
Formally, you need to construct a non-negative integer sequence , where denotes the number of containers placed on shelf . The sequence must satisfy:
- All containers are assigned to shelves, i.e., .
- The total electricity cost satisfies .
Among all valid assignment plans, output the minimum possible value of . If no valid plan exists, output .
Input Format
The input consists of one line containing four integers , representing the number of containers, the number of shelves, the lower bound of the total electricity cost, and the upper bound of the total electricity cost.
Output Format
Output one line containing one integer, the minimum possible value of .
If no valid plan exists, output .
5 3 13 14
3
Hint
Sample Explanation
The following two plans both satisfy the total electricity cost constraint:
- , with total electricity cost , and .
- , with total electricity cost , and .
The first plan has a smaller maximum number of containers on any shelf. It can be proven that there is no valid plan with less than , so the answer is .
Constraints
For of the testdata, it is guaranteed that .
For all testdata, it is guaranteed that and .
Translated by ChatGPT 5