The question is the element of the maximum priority in the queue. If the first line is not the maximum permission, put it at the end of the team. The question requires a given position to calculate the departure time.
Use an array to save the maximum permissions and then sort them. Check whether the first element of the team has the same permissions as the corresponding position of the array. If the permissions are the same, the team leaves the team. Otherwise, the team is placed at the end of the team.
# include
# include
# include
using namespace STD; struct job {int priority; int number; job (INT priority, int number) {This-> priority = priority; this-> Number = Number ;}job () {}}; bool CMP (int, Int B) {return A> B;} int main () {queue
q; int B [101]; INT cases; int n, m; int, count, result; job TMP; CIN> cases; while (cases --) {COUNT = 0; Result = 0; CIN> N> m; for (INT I = 0; I
A; B [I] = A; q. push (JOB (A, I);} Sort (B, B + N, CMP); While (1) {If (Q. front (). priority! = B [count]) {TMP = Q. front (); q. pop (); q. push (TMP);} else {result ++; count ++; If (Q. front (). number = m) break; q. pop () ;}} cout