#P1704. 寻找最优美做题曲线
寻找最优美做题曲线
Description
Luogu OJ has a fun judging feature that automatically draws a user's "problem-solving curve." This curve is a polyline defined as follows: suppose a user solved problems on day , where are strictly increasing. Then the user's problem-solving curve is the polyline passing through the points in order. For example, if you solved problems on day , on day , and on day , then your problem-solving curve over the first days is the continuous polyline from to to .
nodgd can predict how many problems he would be able to AC on each of the next days. He also has an obsession with being strictly increasing, so he forces his problem-solving curve to be strictly increasing. For some reasons, on certain days (a total of days), he must solve problems, and the number of problems solved on those days must exactly match the predicted numbers (showcasing nodgd’s divine prediction). He wants to know, under these constraints, the maximum number of days on which he can solve problems. However, since he still has a pile of math, physics, English, art, and PE competition problems to do, he is asking you to compute it for him.
Input Format
- The first line contains two positive integers and , meaning nodgd has predictions for the next days, among which days are mandatory.
- The second line contains distinct positive integers , indicating that day is mandatory (the are not guaranteed to be in increasing order).
- The third line contains positive integers , where on day , if nodgd solves problems, the number must be exactly .
Output Format
Output a single line.
- If a strictly increasing problem-solving curve can be constructed, output a single positive integer: the maximum number of days on which nodgd can solve problems.
- If no strictly increasing curve exists, output
impossible.
13 4
2 13 8 7
6 10 9 8 9 10 11 16 14 12 13 14 18
5
Hint
Constraints
For all testdata,
- , ;
- , and all are distinct; the are not guaranteed to be in increasing order;
- 。
Translated by ChatGPT 5
京公网安备 11011102002149号