2023 Huawei OD Machine Test Real Questions Paper B Java Implementation [Queue Game]

Table of contents

topic

Ideas

Code


topic

The new teacher lined up the students in the class. Each student has an influence value. Some students are stubborn and will not listen to the teacher and choose their own positions. The non-thorny students are ranked in the remaining positions according to their ability values ​​from small to large. For non-thorny students, if it is found that there are classmates with higher ability values ​​than him in front of him, his degree of dissatisfaction will increase, and the increased amount is equal to the number of classmates with higher ability values ​​than him. The thorny head will not be dissatisfied if the entire class accumulates If the degree of dissatisfaction exceeds k, then the teacher will not be able to teach this class.
Input description The input
has three lines:
the first line is n, m, k, separated by spaces, which respectively represent the total number of students in the class, the number of thorns, and the maximum degree of dissatisfaction k.

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

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

Output description
0 means the teacher can continue to teach this class
1 means the teacher cannot continue to teach this class
Description :
n range is [1,10000]
m range is [1,n]<

Guess you like

Origin blog.csdn.net/misayaaaaa/article/details/132775215
Recommended