Codeforces Round #747 (Div. 2)
Codeforces Round #747 (Div. 2)
F - Ideal Farm
let \(s_i=\sum_{k\le i}a_i\)
The Farm is ideal only if there exist \(s_i=s_j+k\).
let \(t_i=s_i+k\), \(t_0=k\)
The Farm is ideal only if for all possible \(\{a_n\}\), a \(s_i\) coincides with \(t_j\).
Since \(s_i,t_i \in[1, s + k]\), we can calculate the maximum possible \(n\).