3 2 1 4 2 10 4 2 6
10
* It is possible to make the camels cross the bridge without it collapsing by, for example, arranging them in the order $1$, $3$, $2$ from front to back, and setting the distances between them to be $0$, $10$.
* For Part $1$ of the bridge, there are moments when only Camel $1$ and $3$ are inside the part and moments when only Camel $2$ is inside the part. In both cases, the sum of the weights of camels does not exceed $4$ - the weight capacity of Part $1$ - so there is no collapse.
* For Part $2$ of the bridge, there are moments when only Camel $1$ and $3$ are inside the part and moments when only Camel $2$ is inside the part. In both cases, the sum of the weights of camels does not exceed $6$ - the weight capacity of Part $2$ - so there is no collapse.
* Note that the distance between two camels may be $0$ and that camels on endpoints of a part are not considered to be inside the part.2 1 12 345 1 1
\-1 * Print `-1` if the bridge will unavoidably collapse.
8 1 1 1 1 1 1 1 1 1 100000000 1
700000000
8 20 57 806 244 349 608 849 513 857 778 993 939 864 152 984 308 975 46 860 123 956 21 950 850 876 441 899 249 949 387 918 34 965 536 900 875 889 264 886 583 919 88 954 845 869 208 963 511 975
3802
{
"problem": {
"name": "Camels and Bridge",
"description": {
"content": "There are $N$ camels numbered $1$ through $N$. The weight of Camel $i$ is $w_i$. You will arrange the camels in a line and make them cross a bridge consisting of $M$ parts. Before they cross the bridg",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc105_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "There are $N$ camels numbered $1$ through $N$.\nThe weight of Camel $i$ is $w_i$.\nYou will arrange the camels in a line and make them cross a bridge consisting of $M$ parts.\nBefore they cross the bridg...",
"is_translate": false,
"language": "English"
}
]
}