4 3 3 3 4
1
For example, if $P = (2, 3, 1, 4)$, then $F(P)$ is determined to be $(3, 3, 3, 4)$ by the following steps:
* Initially, $B = (1, 2, 3, 4)$.
* The smallest integer $i$ such that $B_i \lt P_{B_i}$ is $1$. Replace $B_1$ with $P_{B_1} = 2$, making $B = (2, 2, 3, 4)$.
* The smallest integer $i$ such that $B_i \lt P_{B_i}$ is $1$. Replace $B_1$ with $P_{B_1} = 3$, making $B = (3, 2, 3, 4)$.
* The smallest integer $i$ such that $B_i \lt P_{B_i}$ is $2$. Replace $B_2$ with $P_{B_2} = 3$, making $B = (3, 3, 3, 4)$.
* There are no more $i$ that satisfy $B_i \lt P_{B_i}$, so the process ends. The current $B = (3, 3, 3, 4)$ is defined as $F(P)$.
There is only one permutation $P$ such that $F(P) = A$, which is $(2, 3, 1, 4)$.4 2 2 4 3
0
8 6 6 8 4 5 6 8 8
18
{
"problem": {
"name": "Chmax",
"description": {
"content": "For a permutation $P = (P_1, P_2, \\dots, P_N)$ of $(1, 2, \\dots, N)$, we define $F(P)$ by the following procedure: * There is a sequence $B = (1, 2, \\dots, N)$. As long as there is an integer",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc171_b"
},
"statements": [
{
"statement_type": "Markdown",
"content": "For a permutation $P = (P_1, P_2, \\dots, P_N)$ of $(1, 2, \\dots, N)$, we define $F(P)$ by the following procedure:\n\n* There is a sequence $B = (1, 2, \\dots, N)$. \n As long as there is an integer...",
"is_translate": false,
"language": "English"
}
]
}