QUE1

2
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
2
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
3
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
9
2 4 8 1 7 5 9 8 3
5 0 2 8 3 2 0 0 4
3
8
10 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
9
2 4 10 1 7 5 9 8 3
5 0 2 8 3 2 0 0 4
3
8
5 3 7 6 4 8 2 9
1 3 2 3 3 1 3 0
5
33 11 22 44 55
0 2 1 1 0
8
3 2 4 2 1 4 6 7
2 4 2 2 4 2 1 0
3
8
5 3 7 6 4 8 2 9
1 3 2 3 3 1 3 0
5
33 11 22 44 55
0 2 1 1 0
6
3 2 1 4 10 7
2 2 4 2 0 0
1
6
2 4 6 8 3 1
1 0 3 2 1 0
1
6
2 4 6 8 3 1
1 0 0 2 1 0
1
6
2 4 6 8 3 1
1 0 1 0 1 5
2
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
3
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 21
6
2 4 6 8 3 1
1 0 3 2 1 0
5
33 11 22 44 55
0 2 1 1 0
3
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2 1
6
2 4 6 8 3 1
1 0 3 2 1 0
5
33 11 22 44 55
0 2 1 1 0
1
6
2 4 6 8 3 1
1 0 3 2 1 0
1
6
2 4 6 8 3 1
1 0 0 2 1 0
1
5
33 11 22 44 55
0 2 1 1 0
#include
void swap (int a[], int left, int right)
{
int temp;
temp=a[left];
a[left]=a[right];
a[right]=temp; 
}//end swap

//end quicksort

int partition( int arr[],int abc[], int low, int high )
{
int left, right;
int pivotItem;
left = low; 
int pivot = left; 
pivotItem = arr[pivot]; 
right = high;
while(leftpivotItem)
right–;
if(left low )
{
pivot = partition( a,abc, low, high );
quicksort( a,abc, low, pivot-1 );
quicksort( a,abc, pivot+1, high );
}
} 
void queue(int arr[],int abc[],int len)
{ 
int temp[1000]={0};

quicksort(arr,abc,0,len-1);
/*for(int i=0;i=0;i–)
{
if(abc[i]==temp[i])
continue;
else
{
int j=i;
if(temp[j]arr[j+1])
temp[j+1]++;
j++;

}
if(temp[j]>abc[j])
while(temp[j]!=abc[j] && jarr[j-1])
temp[j-1]–;
j–;

}

}
}

}
int main()
{
int no;
scanf(“%d”,&no);
if(no>0 && no<=100 && getchar())
while(no–>0)
{
int arr[1000],abc[1000];
int elements ;
scanf(“%d”,&elements);
int len=elements;
if(elements<=1000 && getchar())
while(–elements>=0)
{
scanf(“%d”,&arr[elements]);

}
elements=len;
if(getchar())
while(–elements>=0)
{
scanf(“%d”,&abc[elements]);
}
if(getchar())
queue(arr,abc,len);
for(int i=0;i
3
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
8
2 4 8 1 7 5 9  3
5 0 2 8 3 2 0 4
3
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
8
2 4 8 1 7 5 9  3
5 0 2 7 3 2 0 4
3
8
8 3 2 8 7 4 9 5
0 4 5 0 3 0 0 2
5
33 11 22 44 55
0 2 1 1 0
9
2 4 8 1 7 5 9 8 3
5 0 2 8 3 2 0 0 4
1
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2
1
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2
#include
void swap (int a[], int left, int right)
{
int temp;
temp=a[left];
a[left]=a[right];
a[right]=temp; 
}//end swap

//end quicksort

int partition( int arr[],int abc[], int low, int high )
{
int left, right;
int pivotItem;
left = low; 
int pivot = left; 
pivotItem = arr[pivot]; 
right = high;
while(leftpivotItem)
right–;
if(left low )
{
pivot = partition( a,abc, low, high );
quicksort( a,abc, low, pivot-1 );
quicksort( a,abc, pivot+1, high );
}
} 
void queue(int arr[],int abc[],int len)
{ 
int temp[1000]={0};

quicksort(arr,abc,0,len-1);
/*for(int i=0;i=0;i–)
{
if(abc[i]==temp[i])
continue;
else
{
int j=i;
if(temp[j]arr[j+1])
temp[j+1]++;
j++;

}
if(temp[j]>abc[j])
while(temp[j]!=abc[j] && jarr[j-1])
temp[j-1]–;
j–;

}

}
}

}
int main()
{
int no;
scanf(“%d”,&no);
if(no>0 && no<=100 && getchar())
while(no–>0)
{
int arr[1000],abc[1000];
int elements ;
scanf(“%d”,&elements);
int len=elements;
if(elements<=1000 && getchar())
while(–elements>=0)
{
scanf(“%d”,&arr[elements]);

}
elements=len;
if(getchar())
while(–elements>=0)
{
scanf(“%d”,&abc[elements]);
}
if(getchar())
queue(arr,abc,len);
for(int i=0;i
1
8
5 3 7 6 4 8 2 9
1 3 2 3 3 1 3 0
2
8
8 3 2 8 7 4 9 5
1 4 5 0 3 0 0 2
3
11 22 33 44 55
0 0 1 0 1
5
11 22 33 44 55
0 0 1 0 1
1
5
33 11 22 44 55
0 0 0 0 0
1
5
33 11 22 44 55
0 1 0 0 0
1
5
33 11 22 44 55
0 1 2 0 0
1
5
33 11 22 44 55
0 0 1 0 0
1
5
33 11 22 44 55
0 0 2 0 0
1
5
33 11 22 44 55
0 1 2 0 1
1
5
33 11 22 44 55
0 1 2 1 0
1
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
1
8
8 3 2 8 7 4 9 5
0 4 5 0 3 0 0 2
1
8
8 3 2 8 7 4 9 5
5 4 5 0 3 0 0 2
1
9
2 4 8 1 7 5 9 8 3
5 0 2 8 3 2 0 0 4
2
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
2
5
33 11 22 44 55
0 2 1 1 0
8
8 3 2 8 7 4 9 5
2 4 5 0 3 0 0 2
1
5
1 2 3 4 5
1 2 1 2 0
1
5
33 11 22 44 55
0 2 1 1 0
3
5
33 11 22 44 55
0 2 1 1 0
5
3 4 5 2 1 
0 0 0 0 0
3

5
33 11 22 44 55
0 2 1 1 0

5
3 4 5 2 1 
0 0 0 0 2
3

5
33 11 22 44 55
0 2 1 1 0
5
3 4 5 2 1 
0 0 0 0 2
10
1 2 3 4 5 6 7 8 9 10
0  1 2 3 4 5 6 7 8  9 

1
1 2 3 4 5 6 7 8 9 10
0  1 2 3 4 5 6 7 8  9 

1
1
1 2 3 4 5 6 7 8 9 10
0  1 2 3 4 5 6 7 8  9 

1
10
1 2 3 4 5 6 7 8 9 10
0  1 2 3 4 5 6 7 8  9 

1
10
1 2 3 4 5 6 7 8 9 1
0  1 2 3 4 5 6 7 8  9 

1
10
1 2 3 4 5 6 7 8 9 1
0  1 2 3 4 5 6 1 8  9 

1
10
1 2 3 4 5 6 7 8 9 1
0  1 2 3 1 5 6 1 8  9 

1
5
1 4 5 6 9