{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eBạn được cho một mảng gồm $$$n$$$ số nguyên $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$, và một tập hợp $$$b$$$ gồm $$$k$$$ số nguyên phân biệt từ $$$1$$$ đến $$$n$$$.\u003c/p\u003e\u003cp\u003eTrong một phép thao tác, bạn có thể chọn hai số nguyên $$$i$$$ và $$$x$$$ ($$$1 \\le i \\le n$$$, $$$x$$$ có thể là bất kỳ số nguyên nào) và gán $$$a_i :\u003d x$$$. Phép thao tác này chỉ được thực hiện nếu $$$i$$$ không thuộc tập hợp $$$b$$$.\u003c/p\u003e\u003cp\u003eTính số lần thao tác tối thiểu bạn cần thực hiện để mảng $$$a$$$ tăng dần (nghĩa là $$$a_1 \u0026lt; a_2 \u0026lt; a_3 \u0026lt; \\dots \u0026lt; a_n$$$), hoặc báo cáo nếu không thể thực hiện được.\u003c/p\u003e"}},{"title":"Nhập","value":{"format":"HTML","content":"\u003cp\u003eDòng đầu tiên chứa hai số nguyên $$$n$$$ và $$$k$$$ ($$$1 \\le n \\le 5 \\cdot 10^5$$$, $$$0 \\le k \\le n$$$) — kích thước của mảng $$$a$$$ và tập hợp $$$b$$$, tương ứng.\u003c/p\u003e\u003cp\u003eDòng thứ hai chứa $$$n$$$ số nguyên $$$a_1$$$, $$$a_2$$$, ..., $$$a_n$$$ ($$$1 \\le a_i \\le 10^9$$$).\u003c/p\u003e\u003cp\u003eSau đó, nếu $$$k \\ne 0$$$, dòng thứ ba sẽ chứa $$$k$$$ số nguyên $$$b_1$$$, $$$b_2$$$, ..., $$$b_k$$$ ($$$1 \\le b_1 \u0026lt; b_2 \u0026lt; \\dots \u0026lt; b_k \\le n$$$). \u003cspan class\u003d\"tex-font-style-bf\"\u003eNếu $$$k \u003d 0$$$, dòng này sẽ được bỏ qua\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Xuất","value":{"format":"HTML","content":"\u003cp\u003eNếu không thể làm cho mảng $$$a$$$ tăng dần bằng các phép thao tác đã cho, in $$$-1$$$.\u003c/p\u003e\u003cp\u003eNgược lại, in một số nguyên — số lần thao tác tối thiểu bạn phải thực hiện.\u003c/p\u003e"}},{"title":"Ví dụ","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e7 2\n1 2 1 1 3 5 1\n3 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3 3\n1 3 2\n1 2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e5 0\n4 3 1 2 3\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e10 3\n1 3 5 6 12 9 8 10 13 15\n2 4 9\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}