UVa 12100 Printer Queue (exercise 5-7)

Source: Internet
Author: User

Portal: Https://uva.onlinejudge.org/external/121/12100.pdf

Test instructions: The task to be printed in the queue (1 <= n <= 100) with priority (1-9), the print step for each time from the first team to take one, if there is no priority in the queue than the task, print this task; If there is a high priority, put this task at the end of the queue and print the highest priority. It takes 1 minutes per print time to find out when a given task is printed.

Water problem A half-day is a weak slag .....

The worst-case scenario requires MAXN*MAXN space ...

Front rear record before and after position

1#include <bits/stdc++.h>2 using namespacestd;3 4 Const intMAXN =111;5 intt, N, M, _time;6 intque[maxn*MAXN];7 8 voidprocess () {9     intFront =0, rear =N;Ten      while(true){ One         intMaxi =Que[front]; A          for(inti = front; I < rear; ++i) { -             if(Que[i] >Maxi) { -                 if(front = = m) m =Rear; theque[rear++] = que[front++]; -                  Break; -             } -             Else if(i = = Rear-1){ +++_time; -                 if(front = = m)return ; +front++;  A             } at         } -     } - } - intMain () { -CIN >>T; -      while(t--){ in_time =0; -CIN >> N >>m; to          for(inti =0; I < n; ++i) Cin >>Que[i]; + process (); -cout << _time <<Endl; the     } *     return 0; $}

UVa 12100 Printer Queue (exercise 5-7)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.