Huawei OD Machine Test - Queuing Game (Java & JS & Python)

topic description

The new teacher forms a line for the students in the class.

Each student has an influence value.

Some students are thorns and don't know how to listen to the teacher. They choose their own positions. The non-thorns students are ranked according to their ability value in the remaining positions.

For non-stinging students, if he finds that there are students with higher ability values ​​than himself in front of him, his dissatisfaction will increase, and the amount of increase is equal to the number of students with higher ability values ​​than him in front of him.

Stabbing does not generate dissatisfaction.

If the accumulated dissatisfaction level of the whole class exceeds k, then the teacher has no way to teach this class.

enter description

The input has three lines:

The first line is n, m, k, separated by spaces, respectively indicating the total number of class members, the number of thorns, and the maximum degree of dissatisfaction k.

The second line is the position of the thorn head (starting from 0, that is, the subscript of the queue array, for example, 1 means that the second student in the team is the thorn head), and the array of positions is also sorted.

The third line has n numbers, separated by spaces, indicating the ability value of each person in the team arranged by the teacher. Among them, the non-stabbing students must be ranked in order of ability value from small to large.

output description

0 means the teacher can continue teaching the class

1 means the teacher is unable to continue teaching the class

Remark

  • n range is [1,100000]
  • m range is [1,n]
  • k Fan Guo is [1,1000000000]
  • The range of ability value of each student is [1000,100000]

Example

Guess you like

Origin blog.csdn.net/qfc_128220/article/details/132268179