{"problem":{"name":"Distinct Elements on Subsegments","description":{"content":"For an integer array $A=(A_1, A_2, \\ldots, A_{N + K-1})$ ($1 \\leq A_i \\leq N+K-1$), let's construct an array $B=(B_1, B_2, \\ldots, B_N)$, where $B_i$ is the number of distinct elements in $A_i,A_{i+1}","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc059_d"},"statements":[{"statement_type":"Markdown","content":"For an integer array $A=(A_1, A_2, \\ldots, A_{N + K-1})$ ($1 \\leq A_i \\leq N+K-1$), let's construct an array $B=(B_1, B_2, \\ldots, B_N)$, where $B_i$ is the number of distinct elements in $A_i,A_{i+1},\\ldots,A_{i+K-1}$.\nYou are given $B_1, B_2, \\ldots, B_N$. Determine if there exists an array $A$ which could have produced such an array $B$, and if yes, construct one.\nSolve $T$ test cases for each input file.\n\n## Constraints\n\n*   $1 \\le T \\le 5 \\cdot 10^4$\n*   $2 \\le N \\le 2 \\cdot 10^5$\n*   $2 \\le K \\le 2 \\cdot 10^5$\n*   $1 \\le B_i \\le K$\n*   The sum of $N$ in one input file doesn't exceed $2\\cdot 10^5$.\n*   The sum of $K$ in one input file doesn't exceed $2\\cdot 10^5$.\n*   All values in the input are integers.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$T$\n$case_1$\n$case_2$\n$\\vdots$\n$case_T$\n\nEach case is in the following format:\n\n$N$ $K$\n$B_1$ $B_2$ $\\ldots$ $B_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc059_d","tags":[],"sample_group":[["3\n3 3\n1 2 1\n4 3\n1 2 2 1\n6 4\n3 3 3 3 3 3","NO\nYES\n1 1 1 2 2 2 \nYES\n1 2 3 1 2 3 1 2 3"]],"created_at":"2026-03-03 11:01:14"}}