{"trustable":true,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cimg src\u003d\"CDN_BASE_URL/e91735190c72b1d2ce5d706e25777264?v\u003d1714851810\" align\u003d\"right\" hspace\u003d\"10\" vspace\u003d\"10\"\u003eOctopus and Penguin love sports, especially the climb. They step on the most top building of Changsha to view the Yuelu Mountain in weekend and are attracted by the imposing landscape. However, they can\u0027t see the whole mountain because the building is not high enough. Please help them to calculate the total length of surface for mountain they can see.\u003cbr\u003eSuppose Octopus and Penguin\u0027s coordinate is (0,h) and the mountain is composed by n points which satisfy: \u003cbr\u003e1. All points\u0027 coordinates are equal to or larger than zero.\u003cbr\u003e2. The first point is 0, it\u0027s coordinate is (\u003ci\u003ew\u003c/i\u003e\u003csub\u003e0\u003c/sub\u003e, 0)(\u003ci\u003ew\u003c/i\u003e\u003csub\u003e0\u003c/sub\u003e \u0026gt;\u003d 0).\u003cbr\u003e3. n points are listing in ascending sort by x-axis.\u003cbr\u003e4. Odd points\u0027 y-axis is larger than the former one.\u003cbr\u003e5. Even points\u0027 y-axis (except for 0 point) is small than the former one.\u003cbr\u003eCondition 3,4 and 5 is means for three nearby points (\u003ci\u003ew\u003c/i\u003e\u003csub\u003e2k\u003c/sub\u003e, \u003ci\u003eh\u003c/i\u003e\u003csub\u003e2k\u003c/sub\u003e), (\u003ci\u003ew\u003c/i\u003e\u003csub\u003e2k+1\u003c/sub\u003e, \u003ci\u003eh\u003c/i\u003e\u003csub\u003e2k+1\u003c/sub\u003e) and (\u003ci\u003ew\u003c/i\u003e\u003csub\u003e2k+2\u003c/sub\u003e, \u003ci\u003eh\u003c/i\u003e\u003csub\u003e2k+2\u003c/sub\u003e)(\u003ci\u003ek \u003c/i\u003e∈\u003ci\u003eN\u003c/i\u003e\u003csup\u003e*\u003c/sup\u003e,2\u003ci\u003ek\u003c/i\u003e+2\u0026lt;\u003ci\u003en\u003c/i\u003e), satisfied \u003ci\u003ew\u003c/i\u003e\u003csub\u003e2k \u003c/sub\u003e\u0026lt;\u003ci\u003e w\u003c/i\u003e\u003csub\u003e2k+1 \u003c/sub\u003e\u0026lt;\u003ci\u003e w\u003c/i\u003e\u003csub\u003e2k+2\u003c/sub\u003e, \u003ci\u003eh\u003c/i\u003e\u003csub\u003e2k+1 \u003c/sub\u003e\u0026gt;\u003ci\u003e h\u003c/i\u003e\u003csub\u003e2k\u003c/sub\u003e and \u003ci\u003eh\u003c/i\u003e\u003csub\u003e2k+2\u003c/sub\u003e \u0026lt;\u003ci\u003e h\u003c/i\u003e\u003csub\u003e2k+1\u003c/sub\u003e.\u003cbr\u003e6. The last point is (\u003ci\u003ew\u003c/i\u003e\u003csub\u003en-1\u003c/sub\u003e, 0).\u003cbr\u003e\u003cbr\u003eThe figure below corresponding sample input one: \u003cbr\u003e\u003cimg src\u003d\"CDN_BASE_URL/59824d9e82b0a03d3f5626856e6dbe55?v\u003d1714851810\"\u003e "}},{"title":"Input","value":{"format":"HTML","content":"There are several test cases. For each case, the first line is two integers n (0\u0026lt;n\u0026lt;\u003d1000) and h. Then n lines follow and each line is two integers x and y(0\u0026lt;\u003dx,y\u0026lt;\u003d1000) describe the coordinates of mountains. n\u003dh\u003d0 means end of the input."}},{"title":"Output","value":{"format":"HTML","content":"For each case, output the surface length of mountain they can see."}},{"title":"Sample","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 5\r\n0 0\r\n1 1\r\n2 0\r\n5 5\r\n0 0\r\n2 2\r\n3 1\r\n5 3\r\n8 0\r\n5 4\r\n0 0\r\n2 2\r\n3 1\r\n5 3\r\n8 0\r\n0 0\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2.83\r\n7.07\r\n5.66\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}