4 2 1 3
2 Below, let $(i,j)$ denote a pair of a sock of color $i$ and a sock of color $j$. There are $1, 2, 1, 2$ socks of colors $1, 2, 3, 4$, respectively. Creating the pairs $(1,2),(2,3),(4,4)$ results in a total weirdness of $|1-2|+|2-3|+|4-4|=2$, which is the minimum.
5 1 2
0 The optimal solution is to make the pairs $(1,1),(3,3),(4,4),(5,5)$ and leave one sock of color $2$ as a surplus (not included in any pair).
8 5 1 2 4 7 8
2
{
"problem": {
"name": "Socks 2",
"description": {
"content": "Takahashi has $N$ pairs of socks, and the $i$\\-th pair consists of two socks of color $i$. One day, after organizing his chest of drawers, Takahashi realized that he had lost one sock each of colors $",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc334_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Takahashi has $N$ pairs of socks, and the $i$\\-th pair consists of two socks of color $i$. One day, after organizing his chest of drawers, Takahashi realized that he had lost one sock each of colors $...",
"is_translate": false,
"language": "English"
}
]
}