{"problem":{"name":"Sorting a Segment","description":{"content":"Snuke has a permutation $(P_0,P_1,\\cdots,P_{N-1})$ of $(0,1,\\cdots,N-1)$. Now, he will perform the following operation **exactly once**: *   Choose $K$ consecutive elements in $P$ and sort them in as","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc038_b"},"statements":[{"statement_type":"Markdown","content":"Snuke has a permutation $(P_0,P_1,\\cdots,P_{N-1})$ of $(0,1,\\cdots,N-1)$.\nNow, he will perform the following operation **exactly once**:\n\n*   Choose $K$ consecutive elements in $P$ and sort them in ascending order.\n\nFind the number of permutations that can be produced as $P$ after the operation.\n\n## Constraints\n\n*   $2 \\leq N \\leq 200000$\n*   $2 \\leq K \\leq N$\n*   $0 \\leq P_i \\leq N-1$\n*   $P_0,P_1,\\cdots,P_{N-1}$ are all different.\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$P_0$ $P_1$ $\\cdots$ $P_{N-1}$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc038_b","tags":[],"sample_group":[["5 3\n0 2 1 4 3","2\n\nTwo permutations can be produced as $P$ after the operation: $(0,1,2,4,3)$ and $(0,2,1,3,4)$."],["4 4\n0 1 2 3","1"],["10 4\n2 0 1 3 7 5 4 6 8 9","6"]],"created_at":"2026-03-03 11:01:14"}}