{"problem":{"name":"Larger Score","description":{"content":"We have an integer sequence of length $N$: $A=(A_1,A_2,\\cdots,A_N)$. Below in this problem, let the **score** of $A$ be the sum of the first $K$ terms of $A$. Additionally, let $s$ be the score of the","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":3000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"arc138_a"},"statements":[{"statement_type":"Markdown","content":"We have an integer sequence of length $N$: $A=(A_1,A_2,\\cdots,A_N)$. Below in this problem, let the **score** of $A$ be the sum of the first $K$ terms of $A$. Additionally, let $s$ be the score of the sequence $A$ given in input.\nYou can do the following operation any number of times.\n\n*   Choose two adjacent elements of $A$ and swap them.\n\nYour objective is to make the score at least $s+1$. Determine whether the objective is achievable. If it is, find the minimum number of operations needed to achieve it.\n\n## Constraints\n\n*   $2 \\leq N \\leq 4 \\times 10^5$\n*   $1 \\leq K \\leq N-1$\n*   $1 \\leq A_i \\leq 10^9$\n*   All values in input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$A_1$ $A_2$ $\\cdots$ $A_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc138_a","tags":[],"sample_group":[["4 2\n2 1 1 2","2\n\nWe have $s=2+1=3$. The following sequence of operations makes the score at least $4$.\n\n*   $(2,1,1,2) \\to ($swap $A_3$ and $A_4)\\to (2,1,2,1) \\to ($swap $A_2$ and $A_3)\\to (2,2,1,1)$\n\nThe objective is not achievable in one operation, so the minimum number of operations needed is $2$."],["3 1\n3 2 1","\\-1"],["20 13\n90699850 344821203 373822335 437633059 534203117 523743511 568996900 694866636 683864672 836230375 751240939 942020833 865334948 142779837 22252499 197049878 303376519 366683358 545670804 580980054","13"]],"created_at":"2026-03-03 11:01:13"}}