QOJ.ac

QOJ

حد الوقت: 1 s حد الذاكرة: 2048 MB مجموع النقاط: 100

#12515. Giant Step-Baby Step

الإحصائيات

Satoru Gojo is a student at the Denmon Middle School, and his dream is to become a professional soccer player. Although he does not want to go to school because he wants to practice soccer every day, he still dutifully attends school to avoid violating Article 3, Chapter 2 of the Compulsory Education Act.

The road from Satoru Gojo's home to school is a straight line. We represent this road as a number line, where his home is at coordinate $0$ meters and the school is at coordinate $e$ meters.

Through hard practice, Satoru Gojo has learned $k$ types of steps. The $j$-th type of step allows him to move forward by exactly $s_j$ meters. He hopes to apply these steps in soccer matches. To practice these steps as much as possible, Satoru Gojo will not use any other way of moving on his way to school. To avoid being late, he will not jump backward and will only move straight toward the school.

Unfortunately, there are $n$ potholes on this road, with the $i$-th pothole located at coordinate $a_i$ meters. Therefore, if Satoru Gojo lands on coordinate $a_i$ meters, his feet will be injured, preventing him from achieving his dream of becoming a soccer player. This is something he must avoid.

Given the school's coordinate, the locations of the potholes, and the lengths of the steps Satoru Gojo has mastered, he wants you to help him find the best way to walk that satisfies the following conditions:

  1. Avoid all potholes.
  2. Finally, land exactly at $e$ meters.
  3. The number of times the largest step is used should be as large as possible.
  4. If there are multiple ways with the same maximum number of the largest steps, the number of times the second-largest step is used should be as large as possible.
  5. If there are still multiple ways, compare the number of times the third-largest, fourth-largest, ..., $k$-th largest steps are used in the same manner.

Input

n k e
a_1 a_2 a_3 ··· a_n
s_1 s_2 s_3 ··· s_k
  • $n, k, e$ represent the number of potholes, the number of types of steps Satoru Gojo has mastered, and the school's coordinate, respectively.
  • The coordinate of the $i$-th pothole is $a_i$.
  • The length of the $j$-th type of step is $s_j$.

Output

m
p_1 p_2 p_3 ··· p_m
  • $m$ is a positive integer representing the total number of steps taken in the best walking strategy.
  • $p_i$ are all positive integers, representing the coordinate where he lands after the $i$-th step.
  • If the answer is not unique, any valid answer that meets the requirements is acceptable.

If no such walking strategy exists, output a single line containing -1.

Constraints

  • $2 \le e \le 3 \times 10^5$.
  • $0 \le n \le e - 1$.
  • $2 \le k \le e$.
  • $1 \le a_i \le e - 1$.
  • $1 \le s_j \le e$.
  • $1 \le k \times (e - n) \le 3 \times 10^5$.
  • All variables above are integers.
  • All $a_i$ are distinct.
  • All $s_j$ are distinct.

Examples

Input 1

3 2 8
1 3 4
4 2

Output 1

3
2 6 8

Input 2

3 2 9
3 4 1
4 2

Output 2

-1

Input 3

0 4 61
3 5 23 30

Output 3

4
30 53 58 61

Subtasks

Subtask Score Additional Constraints
1 100 No additional constraints.

Note

For each test case, we consider whether the conditions mentioned in the problem description are met:

  • If the output does not conform to the output format or does not satisfy 1., 2., or 3., the score is 0.
  • If the output satisfies 1., 2., and 3. but does not satisfy 4., the score is 0.2.
  • If the output satisfies 1., 2., 3., and 4. but does not satisfy 5., the score is 0.5.
  • If the output satisfies 1., 2., 3., 4., and 5., the score is 1.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.