经典简约
清爽简洁,回归本真
液态水晶
毛玻璃+霓虹光带
赛博朋克
霓虹故障艺术风
🚫
违规操作检测
禁止使用右键菜单
⚠️ 此操作已被系统记录
1

Slalom

📝 题解 🔵 仅限 C++
题目描述
<img align="right" src="http://plg1.cs.uwaterloo.ca/%7Eacm00/090613/E.png" alt="" /> <p> You are competing in a ski slalom, and you need to select the best skis for the race. The format of the race is that there are </p> <i>N</i> <p> pairs of left and right gates, where each right gate is </p> <i>W</i> <p> metres to the right of its corresponding left gate, and you may neither pass to the left of the left gate nor to the right of the right gate. The </p> <i>i</i><sup>th</sup> <p> pair of gates occurs at distance </p> <i>y<sub>i</sub></i> <p> down the hill, with the horizontal position of the </p> <i>i</i><sup>th</sup> <p> left gate given by </p> <i>x<sub>i</sub></i> <p> . Each gate is further down the hill than the previous gate (i.e. </p> <i>y<sub>i</sub></i> <p> &lt; </p> <i>y<sub>i+1</sub></i> <p> for all </p> <i>i</i> <p> ). </p> <p> You may select from <i>S</i> pairs of skis, where the <i>j</i><sup>th</sup> pair has speed <i>s<sub>j</sub></i>. Your movement is governed by the following rule: if you select a pair of skis with speed <i>s<sub>j</sub></i>, you move with a constant downward velocity of <i>s<sub>j</sub></i> metres per second. Additionally, at any time you may move at a horizontal speed of at most <i>v<sub>h</sub></i> metres per second. </p> <p> You may start and finish at any two horizontal positions. Determine which pair of skis will allow you to get through the race course, passing through all the gates, in the shortest amount of time. </p>
输入格式
<p> The first line of input contains the three integers <i>W</i>, <i>v<sub>h</sub></i>, and <i>N</i>, separated by spaces, with 1 &lt;= <i>W</i> &lt;= 10<sup>8</sup>, 1 &lt;= <i>v<sub>h</sub></i> &lt;= 10<sup>6</sup>, and 1 &lt;= <i>N</i> &lt;= 10<sup>5</sup>. </p> <p> The following <i>N</i> lines of input each contain two integers <i>x<sub>i</sub></i> and <i>y<sub>i</sub></i>, the horizontal and vertical positions respectively of the <i>i</i><sup>th</sup> left gate, with 1 &lt;= <i>x<sub>i</sub></i>, <i>y<sub>i</sub></i> &lt;= 10<sup>8</sup>. </p> <p> The next line of input contains an integer <i>S</i>, the number of skis, with 1 &lt;= <i>S</i> &lt;= 10<sup>6</sup>. </p> <p> The following <i>S</i> lines of input each contain one integer <i>s<sub>j</sub></i>, the speed of the <i>j</i><sup>th</sup> pair of skis, with 1 &lt;= <i>s<sub>j</sub></i> &lt;= 10<sup>6</sup>. </p> <h5> I </h5> <pre>3 2 3 1 1 5 2 1 3 3 3 2 1 </pre> <h5> II </h5> <pre>3 2 3 1 1 5 2 1 3 1 3 </pre>
输出格式
<p> If it is impossible to complete the race with any pair of skis, print the lineIMPOSSIBLE. Otherwise, print the vertical speed <i>s<sub>j</sub></i> of the pair of skis that allows you to get through the race course in the shortest time. </p> <h5> I </h5> <pre>2 </pre> <h5> II </h5> <pre>IMPOSSIBLE </pre>
样例
样例输入 1
3 2 3 1 1 5 2 1 3 3 3 2 1
样例输出 1
2
提交代码
请先登录后提交

🤖 AI 解题助手

DeepSeek
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这道题,可以帮你分析思路、提供代码示例。
⚠️ 请先登录后使用