4 4 1 2 10 1 3 1 7 2 2 7 1 1 3 1 2 2 1 3 1000000 2
32 27 18 2000015 For the query on the first day, if the horses bathe in the order $3,1,4,2$, the satisfaction of each horse is as follows: * Horse $3$'s satisfaction is $3$ * Horse $1$'s satisfaction is $1 \times 1 = 1$ * Horse $4$'s satisfaction is $7 \times 2 = 14$ * Horse $2$'s satisfaction is $7 \times 2 = 14$ The total satisfaction in this case is $32$. For the query on the second day, if the horses bathe in the order $4,2,1,3$, the satisfaction of each horse is as follows: * Horse $4$'s satisfaction is $7$ * Horse $2$'s satisfaction is $7 \times 2 = 14$ * Horse $1$'s satisfaction is $3 \times 1 = 3$ * Horse $3$'s satisfaction is $3 \times 1 = 3$ The total satisfaction in this case is $27$. For the query on the third day, if the horses bathe in the order $4,3,2,1$, the total satisfaction is $18$. For the query on the fourth day, if the horses bathe in the order $4,3,1,2$, the total satisfaction is $2000015$.
10 10 340019 2 598908 1 177330 2 575439 2 916653 2 451275 2 762769 2 36625 2 273231 2 367619 2 8 334230 2 8 835378 1 4 777076 2 6 61501 1 4 516395 1 4 35678 2 5 751493 1 3 815798 1 2 369777 2 5 941470 2
9417616 10146681 10549955 9708906 8847525 8463663 7860112 8606740 8516097 9236070
{
"problem": {
"name": "Egoism",
"description": {
"content": "> At AtCoder Ranch, horses bathe themselves. Some horses clean up afterward, while others leave a mess. There are $N$ horses, numbered $1$ to $N$. Horse $i$ ($1 \\leq i \\leq N$) has a **mood** $A_i$ a",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc440_f"
},
"statements": [
{
"statement_type": "Markdown",
"content": "> At AtCoder Ranch, horses bathe themselves. Some horses clean up afterward, while others leave a mess.\n\nThere are $N$ horses, numbered $1$ to $N$. Horse $i$ ($1 \\leq i \\leq N$) has a **mood** $A_i$ a...",
"is_translate": false,
"language": "English"
}
]
}