5 5 2 1 4 3 3 1 2 5 4
8
Here is one way to achieve $\mathrm{LIS}(A) + \mathrm{LIS}(B) = 8$.
* Do the operation with $i = 2$. Now, $A = (5,1,2,4,3)$, $B = (3,2,1,5,4)$.
* Do the operation with $i = 1$. Now, $A = (1,5,2,4,3)$, $B = (2,3,1,5,4)$.
* Do the operation with $i = 4$. Now, $A = (1,5,2,3,4)$, $B = (2,3,1,4,5)$.
Here, $A$ has a longest increasing subsequence $(1,2,3,4)$, so $\mathrm{LIS}(A)=4$, and $B$ has a longest increasing subsequence $(2,3,4,5)$, so $\mathrm{LIS}(B)=4$.5 1 2 3 4 5 1 2 3 4 5
10
You can decide not to perform the operation at all to achieve $\mathrm{LIS}(A) + \mathrm{LIS}(B) = 10$.{
"problem": {
"name": "Two LIS Sum",
"description": {
"content": "For a sequence $P = (P_1, \\ldots, P_N)$, let $\\mathrm{LIS}(P)$ denote the length of a longest increasing subsequence. You are given permutations $A = (A_1, \\ldots, A_N)$ and $B = (B_1, \\ldots, B_N)$ o",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc149_b"
},
"statements": [
{
"statement_type": "Markdown",
"content": "For a sequence $P = (P_1, \\ldots, P_N)$, let $\\mathrm{LIS}(P)$ denote the length of a longest increasing subsequence.\nYou are given permutations $A = (A_1, \\ldots, A_N)$ and $B = (B_1, \\ldots, B_N)$ o...",
"is_translate": false,
"language": "English"
}
]
}