{"problem":{"name":"Sum of Abs 2","description":{"content":"You are given positive integers $N$ and $L$, and a sequence of positive integers $A = (A_{1}, A_{2}, \\dots , A_{N})$ of length $N$. For each $i = 1, 2, \\dots , N$, answer the following question: > De","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc178_c"},"statements":[{"statement_type":"Markdown","content":"You are given positive integers $N$ and $L$, and a sequence of positive integers $A = (A_{1}, A_{2}, \\dots , A_{N})$ of length $N$.\nFor each $i = 1, 2, \\dots , N$, answer the following question:\n\n> Determine if there exists a sequence of $L$ non-negative integers $B = (B_{1}, B_{2}, \\dots, B_{L})$ such that $\\displaystyle \\sum_{j = 1} ^ {L - 1} \\sum_{k = j + 1} ^ {L} |B_{j} - B_{k}| = A_{i}$. If it exists, find the minimum value of $\\max(B)$ for such a sequence $B$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^{5}$\n*   $2 \\leq L \\leq 2 \\times 10^{5}$\n*   $1 \\leq A_{i} \\leq 2 \\times 10^{5}$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$ $L$\n$A_{1}$ $A_{2}$ $\\cdots$ $A_{N}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc178_c","tags":[],"sample_group":[["2 4\n10 5","3\n-1\n\nFor $A_{1} = 10$, if we take $B = (1, 0, 2, 3)$, then $\\displaystyle \\sum_{j = 1} ^ {L - 1} \\sum_{k = j + 1} ^ {L} |B_{j} - B_{k}| = 10$, where $\\max(B) = 3$. No non-negative integer sequence $B$ satisfies the condition with $\\max(B) < 3$, so print $3$ in the first line.\nFor $A_{2} = 5$, there is no non-negative integer sequence $B$ that satisfies the condition, so print `-1` in the second line."],["6 8\n167 924 167167 167924 116677 154308","11\n58\n10448\n10496\n7293\n9645"]],"created_at":"2026-03-03 11:01:13"}}