#P17534. [JAG 2026 Summer Camp #1] Capybara Petting Club
[JAG 2026 Summer Camp #1] Capybara Petting Club
Problem Description
The International Capybara Petting Club is preparing T-shirts for an event. There are four sizes, S, M, L, and XL, in increasing order. The numbers of T-shirts needed are , and , respectively. At the standard color intensity, T-shirts of sizes S, M, L, and XL require , and units of dye, respectively.
The dyeing machine uses an integer intensity . The minimum allowed color intensity is , and is the standard intensity. Thus, must satisfy . If a T-shirt requires units at the standard intensity, dyeing it at intensity uses units. All T-shirts must use the same intensity .
Given units of dye, find the maximum possible intensity such that all T-shirts can be dyed without using more than units. If no such exists, output -1.
Input Format
The input contains test cases. The first line contains an integer (), the number of test cases. Each test case consists of nine integers given in the following format:
n_S n_M n_L n_XL r A B P K
, and denote the numbers of T-shirts of sizes S, M, L, and XL, respectively ($0\le n_{\mathrm{S}},n_{\mathrm{M}},n_{\mathrm{L}},n_{\mathrm{XL}}\le 10^5$ and $n_{\mathrm{S}}+n_{\mathrm{M}}+n_{\mathrm{L}}+n_{\mathrm{XL}}\ge 1$).
The value denotes the factor by which the amount of dye required at the standard intensity increases with each increase in size ().
denotes the total amount of dye available, in units ().
denotes the amount of dye required to dye one size-S T-shirt at the standard intensity, in units ().
denotes the minimum allowed color intensity, and denotes the standard color intensity ().
Output Format
For each test case, output the maximum integer such that and all T-shirts can be dyed using at most units of dye. If no such integer exists, output -1.
3
1 1 1 1 2 15 2 1 12
2 0 1 0 3 8 2 4 10
0 0 0 1 10 1000 1 900000 999999
6
-1
999999