{"problem":{"name":"Draw Your Cards","description":{"content":"There is a deck consisting of $N$ face-down cards with an integer from $1$ through $N$ written on them. The integer on the $i$\\-th card from the top is $P_i$. Using this deck, you will perform $N$ mov","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc260_d"},"statements":[{"statement_type":"Markdown","content":"There is a deck consisting of $N$ face-down cards with an integer from $1$ through $N$ written on them. The integer on the $i$\\-th card from the top is $P_i$.\nUsing this deck, you will perform $N$ moves, each consisting of the following steps:\n\n*   Draw the topmost card from the deck. Let $X$ be the integer written on it.\n*   Stack the drawn card, face up, onto the card with the smallest integer among the face-up topmost cards on the table with an integer greater than or equal to $X$ written on them. If there is no such card on the table, put the drawn card on the table, face up, without stacking it onto any card.\n*   Then, if there is a pile consisting of $K$ face-up cards on the table, eat all those cards. The eaten cards all disappear from the table.\n\nFor each card, find which of the $N$ moves eats it. If the card is not eaten until the end, report that fact.\n\n## Constraints\n\n*   All values in input are integers.\n*   $1 \\le K \\le N \\le 2 \\times 10^5$\n*   $P$ is a permutation of $(1,2,\\dots,N)$ (i.e. a sequence obtained by rearranging $(1,2,\\dots,N)$).\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$N$ $K$\n$P_1$ $P_2$ $\\dots$ $P_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc260_d","tags":[],"sample_group":[["5 2\n3 5 2 1 4","4\n3\n3\n-1\n4\n\nIn this input, $P=(3,5,2,1,4)$ and $K=2$.\n\n*   In the $1$\\-st move, the card with $3$ written on it is put on the table, face up, without stacked onto any card.\n*   In the $2$\\-nd move, the card with $5$ written on it is put on the table, face up, without stacked onto any card.\n*   In the $3$\\-rd move, the card with $2$ written on it is stacked, face up, onto the card with $3$ written on it.\n    *   Now there is a pile consisting of $K=2$ face-up cards, on which $2$ and $3$ from the top are written, so these cards are eaten.\n*   In the $4$\\-th move, the card with $1$ written on it is stacked, face up, onto the card with $5$ written on it.\n    *   Now there is a pile consisting of $K=2$ face-up cards, on which $1$ and $5$ from the top are written, so these cards are eaten.\n*   In the $5$\\-th move, the card with $4$ written on it is put on the table, face up, without stacked onto any card.\n*   The card with $4$ written on it was not eaten until the end."],["5 1\n1 2 3 4 5","1\n2\n3\n4\n5\n\nIf $K=1$, every card is eaten immediately after put on the table within a single move."],["15 3\n3 14 15 9 2 6 5 13 1 7 10 11 8 12 4","9\n9\n9\n15\n15\n6\n-1\n-1\n6\n-1\n-1\n-1\n-1\n6\n15"]],"created_at":"2026-03-03 11:01:14"}}