← Back to Problems
Stop-Out
Medium optimization Simulation & Monte Carlo Probability & Statistics
Time limit: 10 s per test  ·  Memory: 256 MB

A desk trades one asset for T periods under a disclosed regime model. The market opens in a good regime; at the start of each period, a good market switches permanently to bad with probability lambda. The switch is never observed. The return of period t is

R_t = mu_g + sigma * Z_t   while the regime is good
R_t = mu_b + sigma * Z_t   after the switch

with Z_t iid standard normal conditioned on |Z_t| <= 3, and mu_b < 0 < mu_g.

The desk's risk mandate is two numbers: a leverage l and a stop-out level s. Wealth starts at W_0 = 1 and evolves as W_t = W_{t-1} * (1 + l * R_t). The first time W_t <= s, the book is liquidated at a haircut: wealth becomes W_t * (1 - c) and stays there through period T. Submitting s = 0 means no stop-out.

For each case, submit l in [0, L] and s in [0, 1) maximizing V(l, s) = E[ln W_T].

Input

The first line contains the integer C, the number of cases. Each of the next C lines contains T lambda mu_g mu_b sigma c L Vstar, where Vstar is the maximum achievable value of V for the case, provided for reference.

Output

C lines. Line i: l s for case i, separated by a space.

Scoring

The score of a case is

exp(V(l, s) - Vstar)

capped at 1 — the factor by which your mandate's expected terminal log-wealth compounds relative to the best mandate. V is evaluated by the judge with a deterministic high-accuracy recursion under the disclosed model. An output is rejected (score 0 for the file) if the number of lines is wrong, any l is outside [0, L], any s is outside [0, 1), or any value is not a finite real. A file scores the mean over its cases; the total score is the mean over the files.

Constraints

30 <= T <= 60

0.01 <= lambda <= 0.10

0.005 <= mu_g <= 0.03

-0.06 <= mu_b <= -0.015

0.02 <= sigma <= 0.08

0.03 <= c <= 0.10

1 <= L <= 6, and always L * (3 * sigma - mu_b) <= 0.9, so wealth stays strictly positive

Examples

input
2
36 0.0120 0.0197 -0.0157 0.0603 0.0925 4.57 0.9205530928
33 0.0340 0.0091 -0.0183 0.0324 0.0873 6.00 0.03883984716
input
2
47 0.0170 0.0216 -0.0354 0.0748 0.0843 3.46 0.3964656594
49 0.0390 0.0221 -0.0469 0.0349 0.0647 5.93 0.3505781241
Python 3.13 i Execution environment Isolated microVM · 1 vCPU · no internet access Time and memory limits are set per problem Available packages numpy 2.5.0scipy 1.18.0pandas 3.0.0scikit-learn 1.9.0statsmodels 0.15.0cvxpy 1.9.2