Page 1 of 1

### 822 - Queue and A

Posted: Wed Jun 20, 2007 12:19 am
Hi!
My name is Gabriel Gomes and i'm under graduate in USP - Brazil.

I was resolving some problems on the Programming Challenges book and
one code of mine didn't work well (problem 822 - Queue and A). Can anyone help me please?!?

Thanks,

### 822 - Queue and A

Posted: Sat Mar 29, 2014 9:47 am
I know that this problem will keep on asking scenarios until a "0" is input last right? however, my code seemed to be having a runtime error for UVa, but it runs fine on my end. I need ideas for me to keep going, because right now im really stuck.

P.S.: Also I know my code outputs the correct answers already, doesn't it? I tested it several times already.

Code: Select all

``````

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Queue;
import java.util.StringTokenizer;

class Main {

public static void main(String[] args) {
class RequestSet{
private int id;
private int qty;
private int firstReq;
private int timeReq;
private int nextReq;
private int sucReq;
private int initialized;

public RequestSet(int id,int qty,int firstReq,int timeReq,int nextReq){
this.id=id;
this.qty=qty;
this.firstReq=firstReq;
this.timeReq=timeReq;
this.nextReq=nextReq;
sucReq=nextReq;
initialized=0;
}

public void decReq(){//Decreases the time attributes
if(firstReq!=0)
firstReq-=1;
else if((nextReq!=1 || nextReq!=0) && firstReq==0)
nextReq-=1;
}

public int getInitial(){//Determines if the Request set has already enqueued its first element
return initialized;
}

public void setInitial(){
initialized=1;
}

public void decQty(){//Decreases the requests qty of the Request set(When the set enqueues a request to the spool)
qty--;
}

public void restoreReq(){//Replenishes the time remaining until the next Request
nextReq=sucReq;
}

public int getID(){
return id;
}

public int getQty(){
return qty;
}

public int getFReq(){
return firstReq;
}

public int getTimeReq(){
return timeReq;
}

public int getNReq(){
return nextReq;
}
}//End of Class "Request Set"

class Request{

private int topicID;
private int minsNeeded;

public Request(int id, int mins){
topicID = id;
minsNeeded = mins;
}

public void Process(){
minsNeeded-=1;
}

public int getMins(){
return minsNeeded;
}

public int getId(){
}
}//End of Class "Request"

class Server{

private int id;
private int topicsQty;
private ArrayList<Integer> specialty;
private int available;
private int recentJobAgo;
private int occTil;
private int listStanding;

public Server(int id, int qty, int stand){
this.id=id;
topicsQty=qty;
available=1;
specialty = new ArrayList();
occTil=0;
listStanding=stand;
}

public Server(){

}

public int getPosition(){//Returns the position of the agent in the input list(Agent which was inputted first)
return listStanding;
}

public int getRecJ(){//Return the time elapsed after the most recent job
return recentJobAgo;
}

public void display(){
int i;
for(i=0;i<topicsQty;i++){
System.out.printf("%d ",specialty.get(i));
}
}

public void progress(){
if(available==1)//if agent is available, the time elapsed after the most recent job is incremented
recentJobAgo+=1;
else if(available==0 && (occTil==1 || occTil==0)){//case wherein an agent finishes a request. "occTil==0"-occupied til 0 mins
available=1;
occTil=0;
}
else//case where in the agent's still occupied, so we decrease the "Occupied Until" attribute
occTil--;
}

public int isAvailable(){
return available;
}

public void occupy(int time){//Agent begins servicing a request
if(time>0){
available=0;
recentJobAgo=0;
occTil=time;
}
}

public void doneReq(){
available=1;
}

public void learnTopics(int topicID){//Gets the input from the 3rd to the nth input, for agents. Priority topics.
int i;
}

public int canDo(int id, int i){//returns 1 if the topicID is in the agent's ArrayList of topic names
int result=0;
//for(i=0;i<topicsQty;i++){
if(id==specialty.get(i) && available==1){
result=1;
}
//}
return result;
}
}//End of Class "Server"

int topics, servers, i, result, check, rounds=0, minute;
String dump;
ArrayList<Integer> minutes;
Scanner sc = new Scanner(System.in);
int topicID, noReqs, bFirst, timeReq, betReqs, set=0;
//topicID,# of Requests, time before the 1st request, time requirement to process a request, succeeding time between reqs
int agentID, lrndTopics, j, aTopic, k=0;
//agentID, # of priority topics
RequestSet[] requests;
Server[] agent;
Server temp;
String input;
int spoolSize=0;
Request reqTemp;
minutes=new ArrayList();

do{
if(k==0)
{
do{
//System.out.println("Enter 0");
topics=sc.nextInt();
}while(topics>20 || topics<=0);
}
else
{
do{
//System.out.println("Enter 0");
//                    if(rounds<0)
//                    {
//                        topics=sc.nextInt();
//                    }
//                    else
topics=rounds;
}while(topics>20 || topics<=0);
}
dump=sc.nextLine();

requests = new RequestSet[topics];
for(i=0; i<topics; i++)
{
input=sc.nextLine();
StringTokenizer strToken = new StringTokenizer(input);
do{
topicID=Integer.parseInt((String)strToken.nextElement());
}while(topicID<=0);

do{
//System.out.println("Enter 2");
noReqs=Integer.parseInt((String)strToken.nextElement());
}while(noReqs<=0);

do{
//System.out.println("Enter 3");
bFirst=Integer.parseInt((String)strToken.nextElement());
}while(bFirst<0);

do{
//System.out.println("Enter 4");
timeReq=Integer.parseInt((String)strToken.nextElement());
}while(timeReq<=0);

do{
//System.out.println("Enter 5");
betReqs=Integer.parseInt((String)strToken.nextElement());
}while(betReqs<=0);
requests[i] = new RequestSet(topicID,noReqs,bFirst,timeReq,betReqs);
}//Gets inputs for the request sets
do{
servers=sc.nextInt();
}while(servers>5 || servers<=0);

input=sc.nextLine();

agent = new Server[servers];
for(i=0; i<servers; i++)
{
input=sc.nextLine();
StringTokenizer strToken = new StringTokenizer(input);

do{
agentID=Integer.parseInt((String)strToken.nextElement());
}while(agentID<=0);

do{
lrndTopics=Integer.parseInt((String)strToken.nextElement());
}while(lrndTopics<=0);

agent[i] = new Server(agentID, lrndTopics,i);

for(j=0;j<lrndTopics; j++)
{
do{
aTopic=Integer.parseInt((String)strToken.nextElement());
}while(aTopic<=0);
agent[i].learnTopics(aTopic);
}
}//Gets inputs for the agent set

set=0;
minute=0;
//Request processing section
do{
if(set==1)
minute++;

//                System.out.println("minute: "+minute);

for(i=0;i<topics;i++)
{
if(requests[i].getFReq()==0 && requests[i].getInitial()==0)
{
requests[i].decQty();
requests[i].restoreReq();
requests[i].setInitial();
spoolSize++;
}
else if(requests[i].getInitial()==1 && (requests[i].getNReq()==1 || requests[i].getNReq()==0)  && requests[i].getQty()>0)
{
requests[i].decQty();
requests[i].restoreReq();
spoolSize++;
}
else
{
requests[i].decReq();
//System.out.println("decReq");
}
}

//Sorts the agents according to their idle time. Most idle places first
for(i=1;i< servers;i++)
{
for(j=0;j< servers-1;j++)
if(agent[j].getRecJ()<agent[j+1].getRecJ())
{
temp=agent[j];
agent[j]=agent[j+1];
agent[j+1]=temp;
}
}

//Swaps agents when they have equal idle time; however, the agent that was inputted first places first

for(i=0;i< servers-1;i++)
{
if(agent[i].getRecJ()==agent[i+1].getRecJ()){
if(agent[i].getPosition()>agent[i+1].getPosition()){
temp=agent[i];
agent[i]=agent[i+1];
agent[i+1]=temp;
}
}
}

for(i=0;i<servers;i++)
{
agent[i].progress();
}

//Decreases all the time attributes

//Checks all agents if they're qualified to service a topic
for(j=0;j<topics;j++)
{
for(i=0;i<servers;i++)
{
if(spool.peek()!=null)
{
//for(j=0;j<spoolSize;j++){
if(agent[i].canDo(spool.peek().getId(),j)==1)
{
agent[i].occupy(spool.peek().getMins());
spool.remove();
spoolSize--;
//System.out.println("Agent["+i+"] got a request");
}
}
}
}

set=1;
check=0;
result=0;

//Checks all the requests sets' number of remaining topics
for(j=0;j<topics;j++)
{
if(requests[j].getQty()!=0)
check=1;
}

//Checks if all the agents are occupied
for(i=0;i<servers;i++)
{
if(agent[i].isAvailable()==0)
result=1;
}

if(check==0 && result==1)
check=1;

}while(check==1);
rounds=sc.nextInt();
if(rounds!=0)
k++;
}while(rounds!=0);
for(i=0;i<minutes.size();i++)
System.out.println("Scenario "+(i+1)+": All requests are serviced within "+minutes.get(i)+" minutes.");
}
}``````
Sample input:

Code: Select all

``````3
128 20 0 5 10
134 25 5 6 7
153 30 10 4 5
4
10 2 128 134
11 1 134
12 2 128 153
13 1 153
1
128 5 0 1 10
1
13 1 128
0``````
Output:

Code: Select all

``````Scenario 1: All requests are serviced within 195 minutes.
Scenario 2: All requests are serviced within 41 minutes.``````

### Re: 822 - Queue and A

Posted: Wed Apr 02, 2014 12:50 am
Input:

Code: Select all

``````2
1 91 89 79 50
2 92 49 60 19
4
1 1 2
2 2 1 2
3 2 1 2
4 2 1 2
15
1 68 36 23 2
2 9 6 19 60
3 67 10 6 49
4 49 44 23 66
5 81 8 18 35
6 99 85 85 75
7 94 75 94 96
8 29 7 67 28
9 100 95 11 89
10 29 16 10 29
11 32 55 10 15
12 70 48 4 84
13 100 36 63 73
14 42 93 28 47
15 100 35 2 73
3
1 13 1 2 3 4 5 6 7 8 9 11 12 13 14
2 10 2 3 4 5 9 10 11 12 14 15
3 11 1 2 3 4 5 6 7 9 13 14 15
5
1 41 69 57 29
2 41 76 99 22
3 12 58 30 38
4 3 63 31 52
5 7 58 82 81
5
1 3 1 2 3
2 4 1 3 4 5
3 3 1 2 4
4 2 2 4
5 4 1 2 3 5
12
1 38 19 44 83
2 9 51 58 43
3 1 3 86 42
4 1 67 31 63
5 74 23 82 49
6 7 65 69 76
7 91 33 24 75
8 5 1 44 22
9 81 21 8 39
10 11 20 43 17
11 43 92 17 29
12 48 87 52 48
5
1 9 1 2 3 4 6 7 8 9 10
2 6 5 6 9 10 11 12
3 10 2 3 5 6 7 8 9 10 11 12
4 11 2 3 4 5 6 7 8 9 10 11 12
5 8 3 4 5 6 8 9 11 12
1
1 33 11 23 34
3
1 1 1
2 1 1
3 1 1
5
1 11 94 25 10
2 78 37 50 46
3 19 20 52 28
4 89 78 46 13
5 70 73 29 96
4
1 4 1 3 4 5
2 4 1 2 3 4
3 4 2 3 4 5
4 2 1 2
10
1 42 54 54 70
2 11 28 75 63
3 81 47 39 23
4 84 66 89 89
5 28 43 20 45
6 25 27 44 90
7 9 78 50 29
8 19 36 43 50
9 11 87 79 97
10 28 7 77 6
1
1 10 1 2 3 4 5 6 7 8 9 10
17
1 96 73 21 85
2 5 33 5 26
3 27 89 74 72
4 4 10 24 17
5 73 67 61 54
6 71 34 65 52
7 59 56 11 61
8 84 84 40 99
9 37 9 2 60
10 81 31 50 58
11 40 1 5 24
12 33 67 25 28
13 41 99 16 38
14 93 4 26 81
15 86 72 60 88
16 10 9 25 99
17 88 63 51 79
3
1 12 1 3 5 7 8 9 10 11 12 13 14 16
2 8 2 3 5 7 8 10 11 15
3 11 1 2 4 5 6 8 9 12 13 14 17
15
1 42 22 49 10
2 81 48 24 89
3 77 21 1 68
4 37 12 57 86
5 90 88 50 99
6 58 39 52 20
7 58 54 9 100
8 32 8 4 71
9 92 78 39 4
10 81 52 94 62
11 84 16 50 46
12 57 53 27 58
13 100 9 67 28
14 69 26 47 70
15 77 46 40 55
3
1 10 1 2 6 8 9 10 11 12 13 15
2 9 1 2 3 4 5 8 11 12 14
3 7 1 3 4 7 9 10 11
14
1 64 92 67 87
2 67 48 5 47
3 83 18 98 13
4 53 86 74 62
5 64 49 85 18
6 13 5 48 56
7 66 16 73 54
8 58 42 33 19
9 46 67 14 100
10 34 98 21 70
11 84 55 47 71
12 38 77 52 20
13 43 100 55 88
14 8 31 70 2
3
1 5 2 4 5 7 14
2 9 1 3 4 6 7 9 10 11 12
3 7 2 5 7 8 9 11 13
8
1 48 59 53 54
2 67 97 8 25
3 14 40 99 50
4 15 56 50 40
5 32 76 1 81
6 76 68 79 42
7 69 66 58 7
8 42 7 50 89
2
1 6 1 2 3 5 6 8
2 5 4 5 6 7 8
19
1 37 30 79 84
2 33 56 33 2
3 82 41 59 84
4 49 38 6 5
5 80 74 74 67
6 50 100 35 73
7 92 86 64 83
8 82 15 36 98
9 67 18 82 66
10 49 68 32 14
11 47 52 63 42
12 39 54 53 21
13 3 17 70 79
14 90 70 51 56
15 12 67 88 14
16 40 29 71 23
17 17 99 62 52
18 39 56 9 46
19 91 22 48 71
2
1 11 2 3 4 6 8 12 13 15 16 17 19
2 15 1 2 3 5 6 7 9 10 11 12 13 14 15 17 18
3
1 5 18 79 55
2 5 91 80 100
3 77 46 3 80
2
1 3 1 2 3
2 3 1 2 3
16
1 29 4 84 43
2 52 70 98 22
3 19 21 39 88
4 48 58 60 94
5 25 21 26 8
6 20 61 22 33
7 60 73 39 43
8 69 55 76 27
9 33 20 50 11
10 86 17 32 99
11 16 4 39 70
12 58 55 6 51
13 64 9 29 32
14 45 63 89 3
15 5 7 76 79
16 14 75 14 3
3
1 10 1 4 5 7 10 11 12 13 14 16
2 10 1 2 3 4 6 8 9 14 15 16
3 9 1 3 4 9 10 11 12 14 15
9
1 23 53 87 17
2 12 77 53 8
3 48 36 73 46
4 53 64 12 48
5 83 39 10 28
6 33 23 92 52
7 44 0 68 53
8 88 89 93 20
9 39 31 71 79
3
1 7 1 2 3 4 6 7 8
2 6 1 3 6 7 8 9
3 8 1 2 3 4 5 7 8 9
7
1 54 52 80 90
2 54 42 16 40
3 86 77 68 74
4 41 66 87 23
5 80 58 71 79
6 64 4 39 91
7 26 54 87 73
1
1 7 1 2 3 4 5 6 7
7
1 67 40 98 97
2 16 53 36 26
3 99 26 73 12
4 75 64 66 46
5 44 41 12 10
6 87 68 30 19
7 23 76 67 83
4
1 4 3 4 6 7
2 6 2 3 4 5 6 7
3 4 1 3 4 7
4 3 1 2 4
3
1 4 91 75 93
2 42 52 48 28
3 28 9 20 97
4
1 2 1 3
2 3 1 2 3
3 1 1
4 1 2
5
1 34 62 29 35
2 80 92 77 61
3 13 62 9 97
4 39 62 3 1
5 5 2 73 69
4
1 1 3
2 5 1 2 3 4 5
3 4 2 3 4 5
4 4 2 3 4 5
12
1 89 93 49 57
2 58 40 12 89
3 37 100 98 31
4 53 65 92 19
5 14 47 96 81
6 54 41 11 73
7 77 53 27 10
8 71 85 91 63
9 79 100 7 91
10 1 33 15 18
11 83 98 20 13
12 44 73 64 63
4
1 10 1 2 3 4 5 6 7 8 9 11
2 7 4 5 6 8 9 11 12
3 9 1 2 3 5 6 9 10 11 12
4 8 1 2 4 5 9 10 11 12
17
1 63 3 80 69
2 35 6 23 50
3 12 81 13 46
4 21 80 18 27
5 88 28 51 40
6 2 95 37 79
7 25 42 47 62
8 15 95 20 47
9 52 89 64 51
10 31 29 88 86
11 30 44 90 52
12 50 99 97 59
13 78 66 99 48
14 48 49 85 35
15 30 25 92 31
16 13 76 37 63
17 85 68 73 100
2
1 12 1 4 5 7 8 10 11 12 13 14 16 17
2 13 2 3 4 5 6 7 9 10 12 13 14 15 17
12
1 66 47 26 25
2 44 19 1 80
3 95 5 33 51
4 57 56 98 41
5 92 25 83 71
6 27 46 48 18
7 19 71 77 78
8 89 80 37 12
9 93 30 81 14
10 83 11 95 33
11 72 38 11 80
12 31 14 20 61
4
1 9 2 3 4 5 6 8 9 11 12
2 9 1 3 4 6 7 8 9 11 12
3 9 3 5 6 7 8 9 10 11 12
4 6 1 2 4 6 7 12
1
1 4 65 22 66
5
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1
2
1 56 66 32 11
2 37 2 92 41
2
1 2 1 2
2 1 1
12
1 12 5 100 14
2 91 41 85 38
3 11 22 13 20
4 11 32 100 14
5 49 84 35 55
6 44 44 19 71
7 98 38 14 50
8 58 92 3 45
9 43 0 2 54
10 57 22 50 86
11 28 95 70 14
12 75 94 13 69
4
1 10 1 2 3 5 6 7 9 10 11 12
2 5 2 3 6 7 8
3 7 2 3 5 8 9 10 11
4 6 1 4 7 9 10 11
10
1 22 62 94 6
2 43 39 85 23
3 1 66 37 23
4 32 49 46 86
5 95 1 37 2
6 16 40 14 49
7 81 53 54 28
8 60 68 73 54
9 41 74 76 19
10 87 27 34 12
1
1 10 1 2 3 4 5 6 7 8 9 10
7
1 5 21 21 12
2 70 11 73 84
3 54 71 34 95
4 69 64 8 25
5 32 68 23 96
6 33 16 92 62
7 28 0 57 33
5
1 6 1 2 3 4 5 7
2 6 1 2 3 5 6 7
3 6 1 2 3 4 6 7
4 4 3 5 6 7
5 4 2 3 6 7
1
1 19 16 20 26
4
1 1 1
2 1 1
3 1 1
4 1 1
12
1 56 15 1 99
2 57 5 61 75
3 9 87 12 79
4 2 26 72 10
5 68 16 31 50
6 55 74 98 50
7 93 84 91 47
8 58 11 50 60
9 77 99 12 50
10 3 86 77 73
11 49 56 17 40
12 37 45 23 88
3
1 5 2 3 6 7 8
2 9 1 2 4 5 8 9 10 11 12
3 11 1 2 3 4 5 6 7 8 9 11 12
10
1 14 2 34 50
2 22 21 34 51
3 25 7 42 2
4 38 57 96 86
5 49 16 98 48
6 33 72 33 97
7 60 45 61 27
8 10 37 88 9
9 24 93 23 22
10 9 94 26 56
2
1 6 3 4 6 7 8 9
2 7 1 2 3 4 5 7 10
1
1 4 90 43 63
1
1 1 1
7
1 34 92 40 29
2 96 58 56 64
3 36 43 35 10
4 13 5 52 46
5 51 33 85 92
6 73 10 49 79
7 11 77 69 75
1
1 7 1 2 3 4 5 6 7
1
1 24 62 77 40
5
1 1 1
2 1 1
3 1 1
4 1 1
5 1 1
10
1 63 75 7 79
2 92 81 66 52
3 86 59 66 32
4 58 83 100 30
5 97 93 53 72
6 38 27 40 59
7 32 16 45 79
8 4 99 3 25
9 13 1 1 62
10 1 78 64 18
4
1 8 2 3 5 6 7 8 9 10
2 9 1 2 3 4 5 7 8 9 10
3 9 1 2 3 5 6 7 8 9 10
4 5 2 3 6 8 10
5
1 5 45 47 17
2 74 94 3 73
3 4 29 57 96
4 45 95 73 54
5 40 13 41 91
5
1 4 1 3 4 5
2 4 1 2 4 5
3 4 1 2 3 5
4 3 1 3 5
5 4 2 3 4 5
8
1 82 35 25 8
2 88 57 83 9
3 32 2 44 95
4 81 35 1 62
5 2 95 25 36
6 29 17 2 68
7 10 39 85 23
8 51 1 31 92
2
1 7 2 3 4 5 6 7 8
2 5 1 4 6 7 8
7
1 17 94 29 10
2 12 85 90 3
3 53 25 90 24
4 1 46 52 69
5 2 51 18 15
6 58 29 88 61
7 33 85 43 18
5
1 4 2 5 6 7
2 4 1 3 6 7
3 4 1 2 3 7
4 6 1 3 4 5 6 7
5 5 2 3 4 6 7
11
1 45 95 49 34
2 85 39 56 87
3 87 50 62 57
4 9 13 35 14
5 67 33 98 27
6 83 46 36 14
7 4 78 37 36
8 11 43 35 78
9 73 10 49 35
10 13 43 49 56
11 28 98 82 63
1
1 11 1 2 3 4 5 6 7 8 9 10 11
4
1 29 79 25 47
2 100 32 25 75
3 1 94 38 61
4 2 96 10 50
2
1 3 1 2 4
2 3 1 2 3
17
1 79 20 54 53
2 91 29 33 78
3 20 64 52 70
4 45 80 70 14
5 67 27 14 59
6 59 56 77 72
7 12 43 94 50
8 26 40 36 22
9 66 86 57 89
10 10 44 34 89
11 50 30 50 37
12 78 9 53 19
13 38 75 16 66
14 45 35 73 44
15 92 40 27 19
16 2 28 28 62
17 72 95 73 84
3
1 10 2 4 6 9 10 11 12 15 16 17
2 14 1 2 3 4 6 7 9 10 11 12 13 14 15 17
3 11 2 3 5 7 8 10 11 13 14 15 17
2
1 36 76 13 33
2 7 6 40 12
1
1 2 1 2
20
1 75 37 44 70
2 95 65 10 33
3 34 48 68 50
4 94 16 41 81
5 60 63 68 73
6 37 49 65 31
7 63 7 89 77
8 51 13 89 30
9 68 45 13 84
10 24 80 57 75
11 9 95 6 77
12 23 26 64 99
13 66 80 27 83
14 20 98 51 91
15 21 61 100 40
16 76 16 27 40
17 66 65 97 92
18 81 52 9 5
19 65 75 1 15
20 50 78 44 16
5
1 12 2 4 8 9 10 11 12 13 14 17 18 20
2 10 3 6 7 8 9 14 16 17 18 20
3 14 2 3 5 6 7 8 9 10 12 14 15 16 18 20
4 10 1 3 4 6 10 11 14 15 17 18
5 11 2 3 5 6 8 12 13 15 17 19 20
18
1 34 22 97 8
2 92 69 58 58
3 53 80 90 88
4 57 46 12 64
5 38 53 74 84
6 98 62 12 92
7 90 57 53 81
8 14 46 8 7
9 14 34 3 4
10 100 81 92 12
11 49 74 60 34
12 7 9 91 71
13 7 84 52 64
14 95 51 17 63
15 28 73 61 70
16 23 99 35 68
17 1 87 93 89
18 69 36 40 84
5
1 13 2 3 5 7 8 10 11 13 14 15 16 17 18
2 13 1 2 3 4 5 7 10 12 13 14 15 16 17
3 13 1 2 6 7 9 10 11 12 13 14 15 17 18
4 13 2 3 4 5 6 7 8 9 10 11 13 16 18
5 15 1 4 5 6 7 8 10 11 12 13 14 15 16 17 18
9
1 25 90 56 50
2 69 54 71 17
3 18 60 17 35
4 92 43 10 59
5 99 34 4 61
6 12 15 95 88
7 48 22 64 71
8 10 93 6 9
9 29 24 20 13
3
1 7 1 3 5 6 7 8 9
2 3 2 5 6
3 6 2 3 4 5 6 7
10
1 34 62 37 22
2 81 95 18 23
3 29 81 69 13
4 58 4 34 46
5 99 10 82 24
6 56 79 72 43
7 27 61 8 27
8 36 16 85 15
9 96 29 55 74
10 85 53 8 72
2
1 9 1 2 3 4 5 6 7 8 9
2 7 2 4 5 6 7 9 10
18
1 81 12 5 98
2 84 35 56 93
3 87 96 56 44
4 34 86 13 30
5 64 6 25 95
6 42 52 84 10
7 67 36 49 81
8 23 35 41 74
9 90 58 26 45
10 77 16 11 34
11 48 17 17 67
12 27 33 80 81
13 17 27 38 56
14 53 20 94 73
15 19 67 11 94
16 47 100 87 3
17 97 75 96 64
18 25 94 12 7
3
1 14 1 2 3 4 5 6 7 8 9 12 13 14 15 17
2 13 1 2 4 6 7 9 10 12 13 15 16 17 18
3 11 1 2 4 5 6 7 10 11 16 17 18
10
1 65 95 31 38
2 63 55 26 66
3 93 60 41 39
4 91 29 74 91
5 90 22 88 80
6 53 60 17 41
7 43 41 42 38
8 20 4 79 83
9 27 5 58 61
10 74 86 5 35
3
1 8 1 2 3 4 5 6 7 10
2 10 1 2 3 4 5 6 7 8 9 10
3 7 1 3 4 5 8 9 10
10
1 31 20 7 54
2 51 53 41 53
3 34 29 58 70
4 93 65 52 55
5 2 38 25 18
6 26 96 100 35
7 54 84 98 78
8 44 95 70 38
9 29 35 99 77
10 60 76 16 39
5
1 4 4 6 7 10
2 7 1 2 3 5 7 8 10
3 6 3 4 5 6 7 9
4 6 1 2 3 4 5 6
5 7 1 2 4 5 7 9 10
17
1 6 44 60 33
2 32 29 92 45
3 23 36 66 44
4 46 29 7 94
5 66 83 21 12
6 57 36 84 13
7 91 27 48 86
8 17 22 12 84
9 15 37 16 71
10 2 96 65 7
11 24 10 100 31
12 70 82 42 7
13 27 31 69 14
14 89 36 92 4
15 75 63 68 91
16 1 44 31 79
17 5 21 64 46
3
1 13 1 4 5 7 8 9 10 11 12 14 15 16 17
2 15 1 2 3 4 5 6 7 8 9 11 12 13 15 16 17
3 10 1 2 3 5 7 8 11 12 13 17
4
1 53 41 11 99
2 55 12 23 76
3 90 85 88 62
4 2 56 34 70
2
1 4 1 2 3 4
2 3 1 2 3
13
1 21 71 47 45
2 83 58 56 70
3 65 86 10 96
4 56 57 17 43
5 19 100 71 11
6 1 96 40 65
7 18 18 31 72
8 62 59 58 17
9 78 80 8 57
10 10 40 12 15
11 16 44 84 21
12 63 44 44 53
13 31 25 48 67
4
1 7 1 3 9 10 11 12 13
2 7 1 2 3 4 6 8 9
3 7 3 4 8 9 10 11 13
4 10 1 2 3 5 6 7 8 11 12 13
2
1 59 61 77 68
2 37 25 81 53
3
1 2 1 2
2 1 1
3 2 1 2
12
1 23 66 5 16
2 10 28 68 33
3 44 61 89 16
4 88 65 88 8
5 47 83 84 52
6 5 16 57 89
7 77 46 70 9
8 24 40 1 8
9 89 91 23 57
10 10 9 46 42
11 94 22 27 34
12 17 70 1 14
1
1 12 1 2 3 4 5 6 7 8 9 10 11 12
19
1 38 13 75 70
2 86 34 3 10
3 47 78 87 71
4 56 0 53 94
5 32 91 96 88
6 23 42 81 63
7 30 50 95 13
8 72 73 67 51
9 2 63 80 41
10 4 20 62 82
11 45 5 56 100
12 48 67 53 8
13 62 11 97 48
14 41 89 95 77
15 39 1 28 89
16 86 64 11 94
17 23 31 71 42
18 83 86 78 84
19 93 38 80 86
2
1 14 1 2 4 5 6 7 9 11 13 14 16 17 18 19
2 13 1 3 5 7 8 9 10 12 14 15 16 17 18
11
1 21 48 90 42
2 14 60 12 56
3 23 56 40 44
4 32 20 41 62
5 69 89 42 36
6 18 44 61 85
7 33 91 45 25
8 44 22 82 51
9 79 22 49 24
10 55 69 86 60
11 39 10 42 25
4
1 8 1 4 6 7 8 9 10 11
2 8 1 2 4 5 6 7 8 10
3 10 1 2 3 5 6 7 8 9 10 11
4 10 1 2 3 4 6 7 8 9 10 11
2
1 66 16 86 73
2 23 63 83 36
2
1 2 1 2
2 2 1 2
2
1 35 18 13 19
2 38 98 60 23
2
1 2 1 2
2 1 1
18
1 4 74 17 1
2 59 55 12 73
3 36 98 66 59
4 92 14 99 47
5 10 46 22 33
6 49 76 79 59
7 37 29 37 15
8 55 73 89 55
9 29 24 31 5
10 52 13 77 42
11 41 82 67 43
12 1 68 87 17
13 19 36 34 9
14 27 1 16 12
15 58 5 29 4
16 73 46 61 17
17 85 30 21 43
18 92 88 40 98
4
1 11 1 2 6 7 8 10 11 12 13 14 18
2 15 1 2 3 5 7 8 9 10 11 13 14 15 16 17 18
3 9 2 4 6 8 11 12 13 14 16
4 13 1 2 5 6 7 8 9 10 11 13 14 15 17
18
1 21 52 32 4
2 85 32 58 17
3 68 70 52 90
4 46 45 82 77
5 84 51 49 3
6 89 24 53 80
7 99 67 85 42
8 52 91 98 49
9 98 74 78 30
10 77 9 24 36
11 4 0 28 27
12 64 13 97 10
13 76 35 88 45
14 34 20 54 40
15 38 78 24 38
16 2 88 28 21
17 45 6 65 58
18 15 18 34 89
1
1 18 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
8
1 29 9 39 28
2 53 71 95 76
3 67 8 27 21
4 73 49 72 72
5 5 77 66 45
6 95 75 37 98
7 70 21 29 71
8 75 45 68 47
1
1 8 1 2 3 4 5 6 7 8
5
1 81 92 96 87
2 36 45 85 67
3 9 57 12 83
4 50 89 37 17
5 93 75 31 55
5
1 4 2 3 4 5
2 3 1 2 3
3 4 1 3 4 5
4 2 1 4
5 4 1 2 3 4
17
1 81 35 21 39
2 47 81 24 80
3 25 35 78 2
4 32 3 84 73
5 34 80 8 78
6 44 33 79 59
7 70 44 87 74
8 81 52 54 43
9 6 18 62 74
10 87 13 82 85
11 83 56 2 11
12 14 8 20 37
13 86 51 94 28
14 97 13 71 72
15 52 5 97 58
16 75 30 3 2
17 1 12 44 65
2
1 11 1 2 5 6 7 9 10 11 12 13 14
2 15 1 3 4 5 6 8 9 10 11 12 13 14 15 16 17
14
1 56 44 45 15
2 65 68 48 41
3 55 77 30 7
4 67 89 18 62
5 4 23 39 94
6 93 37 6 35
7 79 36 89 60
8 97 21 61 30
9 97 10 87 5
10 44 40 1 86
11 96 7 93 82
12 56 93 28 10
13 52 70 79 66
14 48 18 80 37
3
1 5 6 8 9 11 13
2 8 1 3 4 5 7 9 10 12
3 8 1 2 6 7 10 12 13 14
13
1 10 66 20 29
2 25 8 82 74
3 7 92 74 33
4 3 19 22 85
5 17 46 54 55
6 9 72 88 85
7 8 100 90 98
8 47 74 6 67
9 51 8 20 26
10 37 18 34 53
11 44 2 98 60
12 78 20 9 71
13 99 25 28 15
5
1 7 2 4 6 7 9 11 12
2 9 2 3 4 5 7 8 9 11 13
3 8 1 2 3 4 5 8 9 12
4 11 1 2 4 6 7 8 9 10 11 12 13
5 11 1 2 5 6 7 8 9 10 11 12 13
16
1 18 5 97 5
2 63 11 47 25
3 52 48 54 13
4 84 69 43 46
5 28 32 94 37
6 63 6 79 35
7 10 26 6 81
8 4 25 55 99
9 27 3 76 3
10 35 51 1 23
11 4 98 11 6
12 42 48 20 54
13 100 20 72 14
14 82 87 72 2
15 75 39 88 77
16 49 64 80 95
2
1 14 1 3 4 5 6 7 9 10 11 12 13 14 15 16
2 11 1 2 4 5 6 7 8 9 10 12 13
4
1 20 70 75 80
2 56 43 37 76
3 32 67 37 34
4 24 99 9 46
1
1 4 1 2 3 4
9
1 58 42 55 34
2 6 7 82 86
3 12 23 62 57
4 79 89 47 95
5 68 7 62 45
6 27 21 63 4
7 27 70 61 33
8 22 45 33 88
9 25 70 22 87
4
1 7 1 2 4 5 6 7 9
2 7 1 2 3 4 5 7 9
3 6 1 2 3 4 6 7
4 7 1 3 4 5 6 7 8
7
1 76 17 73 29
2 38 49 97 86
3 91 6 42 17
4 70 31 71 47
5 2 11 86 68
6 50 19 39 23
7 95 48 92 82
1
1 7 1 2 3 4 5 6 7
7
1 37 25 19 99
2 17 7 68 26
3 33 2 8 90
4 44 68 96 29
5 24 86 85 9
6 10 100 5 100
7 91 5 15 15
5
1 4 2 4 5 6
2 5 1 3 4 6 7
3 4 2 3 5 7
4 6 2 3 4 5 6 7
5 3 1 3 5
19
1 41 66 46 98
2 89 58 70 100
3 1 7 54 55
4 7 25 30 10
5 98 18 48 3
6 14 43 79 94
7 93 5 40 15
8 23 32 28 25
9 25 91 57 26
10 33 98 55 79
11 69 33 4 8
12 87 30 45 33
13 38 10 32 92
14 77 14 58 63
15 74 32 64 49
16 17 31 84 92
17 70 7 62 92
18 75 84 6 16
19 45 82 39 61
3
1 15 1 2 3 6 7 8 10 11 12 13 15 16 17 18 19
2 11 2 3 4 5 6 7 9 10 17 18 19
3 14 2 3 4 5 8 9 10 11 12 14 15 16 17 18
16
1 19 100 99 70
2 28 76 45 64
3 95 2 6 21
4 91 31 73 65
5 28 43 87 78
6 40 26 48 46
7 72 31 43 81
8 42 52 31 73
9 44 39 28 29
10 45 88 49 72
11 23 96 64 7
12 17 91 87 88
13 71 36 7 26
14 87 25 55 6
15 70 59 31 97
16 42 10 16 61
4
1 15 1 2 3 4 5 6 7 8 9 10 12 13 14 15 16
2 10 2 3 4 5 6 8 9 10 11 16
3 12 2 3 5 6 7 8 10 12 13 14 15 16
4 10 1 3 4 5 6 7 8 9 11 14
20
1 37 53 19 21
2 69 79 1 76
3 21 96 22 29
4 73 100 86 91
5 36 81 96 78
6 96 25 38 50
7 25 77 54 28
8 80 93 70 8
9 16 35 15 89
10 95 63 7 15
11 71 90 4 29
12 67 37 25 89
13 69 45 22 20
14 38 73 34 11
15 47 95 83 88
16 92 41 18 52
17 98 9 94 32
18 81 68 42 1
19 86 79 59 45
20 55 38 46 35
4
1 12 1 2 3 4 6 7 9 11 12 13 14 16
2 14 3 4 5 6 7 10 12 14 15 16 17 18 19 20
3 13 1 2 5 8 10 11 12 13 15 17 18 19 20
4 13 3 4 5 8 9 11 12 14 16 17 18 19 20
15
1 99 30 50 9
2 83 84 79 67
3 4 67 100 43
4 15 40 5 77
5 91 62 30 12
6 77 23 60 20
7 58 55 11 46
8 50 86 88 41
9 3 43 51 37
10 76 42 2 82
11 29 31 98 1
12 65 1 54 54
13 54 63 10 35
14 19 80 5 21
15 7 91 3 67
5
1 7 4 5 6 8 11 12 13
2 10 1 4 5 6 8 9 10 12 13 14
3 9 1 2 6 7 8 9 10 12 13
4 10 1 2 4 5 6 8 10 11 13 14
5 10 2 3 5 7 10 11 12 13 14 15
4
1 91 41 50 50
2 1 10 38 23
3 40 42 16 75
4 57 52 26 32
2
1 2 1 3
2 4 1 2 3 4
19
1 90 53 21 68
2 85 7 82 11
3 80 1 14 49
4 42 28 97 91
5 30 91 11 12
6 23 70 3 14
7 23 88 24 14
8 9 13 86 42
9 16 88 83 6
10 65 36 40 16
11 96 5 79 6
12 39 14 84 27
13 12 44 46 46
14 13 55 52 100
15 68 38 56 27
16 99 13 68 41
17 18 2 78 2
18 23 25 18 18
19 75 42 81 48
4
1 12 1 2 3 4 5 6 8 9 10 12 17 18
2 15 2 4 5 6 7 8 9 10 12 13 14 15 16 17 19
3 13 1 4 6 7 9 10 11 12 13 14 15 17 18
4 11 1 3 8 9 11 13 15 16 17 18 19
17
1 34 28 53 99
2 20 7 52 48
3 26 37 58 61
4 16 5 3 96
5 39 6 88 16
6 41 4 83 29
7 15 98 1 34
8 17 25 90 19
9 94 97 58 94
10 74 43 3 61
11 8 95 29 13
12 47 40 40 31
13 7 29 20 27
14 87 6 62 54
15 32 91 59 62
16 94 82 96 48
17 66 79 2 6
4
1 10 2 3 4 6 8 11 12 13 14 17
2 11 1 3 4 5 7 11 12 13 14 16 17
3 12 1 2 3 5 9 11 12 13 14 15 16 17
4 11 1 3 6 7 8 9 10 11 14 15 17
6
1 6 4 62 76
2 45 66 100 99
3 82 6 68 94
4 12 65 54 69
5 47 56 19 89
6 41 51 71 99
2
1 6 1 2 3 4 5 6
2 6 1 2 3 4 5 6
12
1 17 36 75 58
2 23 88 21 74
3 14 13 95 14
4 43 97 50 6
5 29 0 22 37
6 84 23 24 31
7 81 2 65 62
8 21 42 51 11
9 51 26 54 78
10 40 14 75 27
11 27 73 63 22
12 1 2 67 13
4
1 6 1 4 5 9 10 12
2 7 3 4 7 8 9 10 12
3 10 1 2 3 5 6 7 8 10 11 12
4 9 1 2 3 4 6 8 9 10 12
15
1 43 5 85 72
2 16 60 63 26
3 94 79 31 28
4 80 72 88 38
5 39 64 60 37
6 39 78 54 46
7 52 8 10 9
8 23 21 66 51
9 79 24 81 2
10 22 82 53 43
11 21 15 69 84
12 93 49 80 56
13 36 36 4 39
14 18 69 59 58
15 71 86 8 21
5
1 13 1 2 3 4 5 7 8 9 10 11 12 14 15
2 10 2 3 4 6 7 8 10 13 14 15
3 8 1 2 4 5 7 8 10 13
4 11 1 2 4 7 8 10 11 12 13 14 15
5 8 2 3 4 5 8 9 13 14
5
1 30 87 16 19
2 65 9 89 75
3 6 23 2 81
4 85 90 39 17
5 67 70 76 27
4
1 3 1 2 5
2 4 1 2 3 5
3 5 1 2 3 4 5
4 3 3 4 5
9
1 50 44 68 1
2 58 33 83 42
3 42 8 36 3
4 21 22 53 17
5 13 7 59 17
6 23 95 26 57
7 47 15 54 98
8 20 84 26 20
9 35 4 1 93
5
1 5 4 5 6 8 9
2 7 1 3 4 5 6 8 9
3 5 1 4 5 8 9
4 6 1 2 3 4 7 8
5 5 1 3 6 7 9
15
1 40 34 66 80
2 99 40 34 91
3 51 8 31 5
4 100 8 1 87
5 49 50 7 9
6 68 83 100 96
7 46 92 86 64
8 32 36 23 100
9 31 46 86 88
10 28 85 94 71
11 63 1 29 77
12 38 98 36 29
13 89 54 98 94
14 13 85 88 50
15 24 19 54 73
2
1 13 1 2 3 4 5 7 8 9 10 11 12 13 15
2 10 3 4 5 6 7 9 11 13 14 15
13
1 30 23 71 65
2 64 69 7 40
3 95 28 58 44
4 64 16 52 58
5 93 91 83 74
6 91 14 8 27
7 45 60 92 20
8 97 22 97 81
9 58 30 26 19
10 27 35 60 84
11 27 32 19 70
12 95 60 53 70
13 13 17 92 35
1
1 13 1 2 3 4 5 6 7 8 9 10 11 12 13
8
1 53 32 77 26
2 88 20 92 31
3 74 14 21 59
4 44 15 64 19
5 1 66 89 96
6 17 8 33 90
7 40 27 67 16
8 83 12 60 6
1
1 8 1 2 3 4 5 6 7 8
2
1 13 42 53 97
2 59 21 3 68
3
1 1 2
2 1 2
3 2 1 2
16
1 45 48 3 32
2 77 89 56 22
3 81 16 67 76
4 5 88 90 3
5 71 77 7 1
6 71 37 5 75
7 19 95 56 84
8 20 16 86 89
9 61 75 51 40
10 86 19 22 58
11 42 26 14 40
12 3 43 13 3
13 46 59 61 71
14 100 55 52 17
15 47 80 54 59
16 83 18 55 91
3
1 11 1 2 3 4 6 7 8 9 10 15 16
2 12 2 3 5 7 8 10 11 12 13 14 15 16
3 14 2 3 4 5 7 8 9 10 11 12 13 14 15 16
8
1 42 95 98 64
2 20 41 50 7
3 69 19 71 11
4 49 33 78 51
5 75 50 21 32
6 50 38 62 15
7 84 18 52 41
8 41 10 4 77
4
1 5 1 2 3 5 7
2 4 1 2 3 7
3 4 1 2 6 8
4 7 1 3 4 5 6 7 8
11
1 95 99 35 69
2 10 94 89 22
3 23 82 43 38
4 91 77 79 21
5 22 0 14 45
6 8 73 37 62
7 59 37 29 42
8 65 49 32 97
9 39 3 20 66
10 97 67 56 60
11 70 76 66 98
2
1 8 1 2 6 7 8 9 10 11
2 9 1 2 3 4 5 8 9 10 11
18
1 76 46 43 34
2 27 33 12 51
3 40 63 66 56
4 48 2 60 1
5 42 13 10 75
6 55 90 53 73
7 59 32 3 26
8 9 21 5 76
9 98 73 77 48
10 43 76 83 88
11 100 97 58 100
12 96 61 30 69
13 12 15 52 39
14 82 93 11 5
15 93 86 80 66
16 32 55 39 85
17 55 38 37 16
18 70 68 4 19
4
1 14 1 2 3 4 5 6 7 8 9 11 13 14 16 17
2 9 1 3 6 8 9 12 15 17 18
3 8 1 2 3 6 10 12 13 16
4 12 1 2 3 4 6 7 10 11 13 14 15 17
2
1 27 94 1 29
2 29 10 83 5
2
1 2 1 2
2 2 1 2
9
1 86 75 7 18
2 65 60 4 32
3 17 18 55 14
4 60 5 69 57
5 31 93 26 47
6 6 21 16 54
7 18 0 46 49
8 52 58 74 35
9 12 51 30 81
3
1 7 1 3 4 5 6 7 8
2 5 2 3 4 7 9
3 6 1 2 3 4 6 9
8
1 77 2 57 80
2 63 10 51 25
3 87 84 4 21
4 55 25 16 87
5 48 12 95 86
6 90 68 35 79
7 7 25 71 14
8 29 74 92 98
5
1 5 1 2 3 4 7
2 7 1 2 3 4 5 7 8
3 7 1 2 3 5 6 7 8
4 6 2 4 5 6 7 8
5 4 1 3 5 7
7
1 61 95 13 17
2 81 82 93 97
3 41 65 11 6
4 68 72 35 39
5 41 19 79 13
6 66 82 100 96
7 62 44 53 13
2
1 7 1 2 3 4 5 6 7
2 7 1 2 3 4 5 6 7
18
1 18 70 60 66
2 15 95 64 26
3 35 57 33 72
4 64 100 14 82
5 67 65 1 95
6 21 1 90 100
7 82 93 43 92
8 70 100 14 53
9 2 28 73 25
10 12 96 82 89
11 95 55 32 14
12 92 28 87 97
13 38 100 18 87
14 3 76 83 60
15 78 21 77 25
16 14 91 54 90
17 15 44 38 27
18 84 82 84 19
5
1 10 1 5 9 11 12 13 14 15 16 17
2 10 1 2 3 4 5 7 8 9 13 15
3 15 1 2 4 5 6 7 8 11 12 13 14 15 16 17 18
4 11 1 2 3 7 8 9 10 11 12 16 17
5 9 1 4 6 8 9 11 13 15 16
11
1 64 75 81 28
2 27 63 41 3
3 49 100 68 40
4 67 86 62 82
5 21 54 48 100
6 35 47 8 97
7 36 7 43 38
8 51 67 11 72
9 97 80 41 43
10 73 33 28 33
11 28 50 82 95
3
1 7 4 5 6 7 8 9 10
2 8 1 2 3 5 6 7 8 9
3 11 1 2 3 4 5 6 7 8 9 10 11
7
1 72 77 28 11
2 72 52 37 37
3 37 93 47 27
4 24 98 50 13
5 69 66 6 53
6 43 30 100 9
7 58 37 34 61
5
1 4 1 2 3 4
2 5 1 3 4 5 6
3 3 1 2 7
4 6 2 3 4 5 6 7
5 4 2 3 5 6
12
1 26 86 10 14
2 19 24 17 56
3 51 11 8 92
4 66 33 11 89
5 7 61 94 69
6 76 91 55 93
7 78 8 22 34
8 21 18 20 56
9 37 25 25 82
10 33 37 34 42
11 34 36 21 94
12 100 95 92 32
1
1 12 1 2 3 4 5 6 7 8 9 10 11 12
3
1 41 49 91 90
2 57 58 72 28
3 34 63 2 36
5
1 1 2
2 3 1 2 3
3 2 2 3
4 3 1 2 3
5 2 2 3
3
1 26 8 89 73
2 59 73 91 2
3 77 96 58 51
4
1 3 1 2 3
2 1 3
3 2 2 3
4 3 1 2 3
20
1 9 84 8 67
2 69 71 11 59
3 78 32 40 89
4 79 53 65 34
5 87 89 24 38
6 14 47 13 78
7 2 49 9 92
8 35 76 53 17
9 70 96 6 12
10 56 41 6 68
11 31 59 26 45
12 80 79 95 91
13 48 9 52 70
14 7 26 87 16
15 64 55 83 47
16 98 48 61 87
17 86 38 45 18
18 99 30 57 3
19 25 48 78 35
20 93 5 42 72
3
1 10 3 5 7 8 9 12 13 14 17 19
2 15 1 2 3 6 7 8 9 10 12 13 15 16 17 19 20
3 16 1 4 6 7 8 9 11 12 13 14 15 16 17 18 19 20
0
``````
AC output:

Code: Select all

``````Scenario 1: All requests are serviced within 4668 minutes.
Scenario 2: All requests are serviced within 13905 minutes.
Scenario 3: All requests are serviced within 1629 minutes.
Scenario 4: All requests are serviced within 6807 minutes.
Scenario 5: All requests are serviced within 1122 minutes.
Scenario 6: All requests are serviced within 6726 minutes.
Scenario 7: All requests are serviced within 19687 minutes.
Scenario 8: All requests are serviced within 13611 minutes.
Scenario 9: All requests are serviced within 20452 minutes.
Scenario 10: All requests are serviced within 16134 minutes.
Scenario 11: All requests are serviced within 9659 minutes.
Scenario 12: All requests are serviced within 30405 minutes.
Scenario 13: All requests are serviced within 6129 minutes.
Scenario 14: All requests are serviced within 11787 minutes.
Scenario 15: All requests are serviced within 8659 minutes.
Scenario 16: All requests are serviced within 25041 minutes.
Scenario 17: All requests are serviced within 6540 minutes.
Scenario 18: All requests are serviced within 2648 minutes.
Scenario 19: All requests are serviced within 4988 minutes.
Scenario 20: All requests are serviced within 8065 minutes.
Scenario 21: All requests are serviced within 23667 minutes.
Scenario 22: All requests are serviced within 16997 minutes.
Scenario 23: All requests are serviced within 285 minutes.
Scenario 24: All requests are serviced within 4302 minutes.
Scenario 25: All requests are serviced within 6020 minutes.
Scenario 26: All requests are serviced within 25800 minutes.
Scenario 27: All requests are serviced within 5880 minutes.
Scenario 28: All requests are serviced within 504 minutes.
Scenario 29: All requests are serviced within 8597 minutes.
Scenario 30: All requests are serviced within 9167 minutes.
Scenario 31: All requests are serviced within 322 minutes.
Scenario 32: All requests are serviced within 17348 minutes.
Scenario 33: All requests are serviced within 1059 minutes.
Scenario 34: All requests are serviced within 8250 minutes.
Scenario 35: All requests are serviced within 5426 minutes.
Scenario 36: All requests are serviced within 8794 minutes.
Scenario 37: All requests are serviced within 3594 minutes.
Scenario 38: All requests are serviced within 29281 minutes.
Scenario 39: All requests are serviced within 7482 minutes.
Scenario 40: All requests are serviced within 13857 minutes.
Scenario 41: All requests are serviced within 1244 minutes.
Scenario 42: All requests are serviced within 9540 minutes.
Scenario 43: All requests are serviced within 8998 minutes.
Scenario 44: All requests are serviced within 6016 minutes.
Scenario 45: All requests are serviced within 14398 minutes.
Scenario 46: All requests are serviced within 15250 minutes.
Scenario 47: All requests are serviced within 9586 minutes.
Scenario 48: All requests are serviced within 6255 minutes.
Scenario 49: All requests are serviced within 15275 minutes.
Scenario 50: All requests are serviced within 5691 minutes.
Scenario 51: All requests are serviced within 6240 minutes.
Scenario 52: All requests are serviced within 4082 minutes.
Scenario 53: All requests are serviced within 27173 minutes.
Scenario 54: All requests are serviced within 31562 minutes.
Scenario 55: All requests are serviced within 6080 minutes.
Scenario 56: All requests are serviced within 4847 minutes.
Scenario 57: All requests are serviced within 2439 minutes.
Scenario 58: All requests are serviced within 11049 minutes.
Scenario 59: All requests are serviced within 63993 minutes.
Scenario 60: All requests are serviced within 24214 minutes.
Scenario 61: All requests are serviced within 7148 minutes.
Scenario 62: All requests are serviced within 27650 minutes.
Scenario 63: All requests are serviced within 20282 minutes.
Scenario 64: All requests are serviced within 5496 minutes.
Scenario 65: All requests are serviced within 31022 minutes.
Scenario 66: All requests are serviced within 5015 minutes.
Scenario 67: All requests are serviced within 7546 minutes.
Scenario 68: All requests are serviced within 28894 minutes.
Scenario 69: All requests are serviced within 3608 minutes.
Scenario 70: All requests are serviced within 15352 minutes.
Scenario 71: All requests are serviced within 9299 minutes.
Scenario 72: All requests are serviced within 15141 minutes.
Scenario 73: All requests are serviced within 6390 minutes.
Scenario 74: All requests are serviced within 4591 minutes.
Scenario 75: All requests are serviced within 16068 minutes.
Scenario 76: All requests are serviced within 11328 minutes.
Scenario 77: All requests are serviced within 7688 minutes.
Scenario 78: All requests are serviced within 6724 minutes.
Scenario 79: All requests are serviced within 10384 minutes.
Scenario 80: All requests are serviced within 4898 minutes.
Scenario 81: All requests are serviced within 5742 minutes.
Scenario 82: All requests are serviced within 19597 minutes.
Scenario 83: All requests are serviced within 43298 minutes.
Scenario 84: All requests are serviced within 24865 minutes.
Scenario 85: All requests are serviced within 3968 minutes.
Scenario 86: All requests are serviced within 11602 minutes.
Scenario 87: All requests are serviced within 6695 minutes.
Scenario 88: All requests are serviced within 13838 minutes.
Scenario 89: All requests are serviced within 12410 minutes.
Scenario 90: All requests are serviced within 1271 minutes.
Scenario 91: All requests are serviced within 6234 minutes.
Scenario 92: All requests are serviced within 7134 minutes.
Scenario 93: All requests are serviced within 12182 minutes.
Scenario 94: All requests are serviced within 12546 minutes.
Scenario 95: All requests are serviced within 10323 minutes.
Scenario 96: All requests are serviced within 3676 minutes.
Scenario 97: All requests are serviced within 20660 minutes.
Scenario 98: All requests are serviced within 3740 minutes.
Scenario 99: All requests are serviced within 4030 minutes.
Scenario 100: All requests are serviced within 19775 minutes.
``````
Note that there is a case in the judge's input where a person covers 0 topics, violating the problem description.

### Re: 822 - Queue and A

Posted: Tue Jan 17, 2017 1:54 am
Out of 100 Brian's cases, my code produces 77 correctly. My algo is as follows. For the second test case, for instance, my code produces 13902, three minutes short of the correct answer. How the staff members get assigned to jobs? I do it in rounds. First, each staff members selects herself a request that came into the door -- making sure it is the highest-in-priority available. Of course, that job itself keeps track of the "best" applicant, in terms of "most recent scheduled time" etc. Once a round is complete, I remove the worker from the pool, its job from the list, and do another round. When I am unable to match in such way any longer, I add the unprocessed jobs into the queue and do the outer loop again. There is a subtle bug with this logic, not sure where...

### Re: 822 - Queue and A

Posted: Tue Jan 17, 2017 3:05 pm
I believe judge's input is incomplete. I got Accepted, but my output differs from the above in 23 cases from the 100.