# Time limit: 1000ms   Memory limit: 65536kb

Pass rate: 218 / 338   (64.50%)     Accuracy: 218 / 1249   (17.45%)

## Title Description

At the beginning of school, the guide will   nn   Three students form a temporary class, but they think there are too many students in the class, so they give you a transcript of all students, and let you divide them into different regular classes according to everyone's grades as follows:

1. If the total number of the temporary shift is less than   kk, then it becomes the last regular class (the class number is   s+1s+1  ,  ss   For the number of regular classes that have been assigned, obviously at the beginning   s=0s=0  )， And end the shift.
2. Start with the first student and put the continuous   kk   Students are divided into a regular class (if there are not enough students in the last class)   kk   People, then they will be merged to the previous shift), and the shift numbers are   s+1,s+2,s+3,…,s+ms+1,s+2,s+3,…,s+m   (suppose it's separated   mm   Class).
3. Separate from the previous step   mm   The highest scores of each class are moved out in turn to form a temporary class (these students will no longer belong to the original class), and the class is divided again (back to the second class)   eleven   Step).

You should also pay attention to the following points during shift assignment:

• The relative order of students remains unchanged before and after class division, such as students   aa   yes   eleven   The highest score in the class, students   bb   yes   twenty-two   The highest score of the class, after they move out to the same temporary class   aa   Should also be ranked   bb   front.
• Only regular classes have a class number, and from   eleven   It starts to increase in turn. There is no shift number for the temporary shift.
• Record the minimum score of each regular shift, and finally output the minimum score of each shift according to the shift number sequence.

## input

The first line contains two integers   nn   and   kk

Second line   nn   Integer   xx  ， Indicates the grade of each student

## output

Multiline output, 2nd   ii   Row output   ii   Minimum score of class

## sample input

```10 3
10 23 21 89 11 43 56 99 60 78```

```10
11
56
23
99```

## Example description

First divide into 1 class: (10, 23, 21), 2 classes: (89, 11, 31), 3 classes: (56, 99, 60, 78), and then take out the highest score of each class to form a temporary class: (23, 89, 99). The number of people in this class is not less than k (k=3), and continue to divide into classes. Divide the class into 4 classes: (23, 89, 99), and take out the highest score to form a temporary class: (99). At this time, there is only 1 person in the temporary class (less than k) At the end of the shift, the temporary shift becomes 5 shifts. Finally, the lowest scores of shifts 1 to 5 are output in sequence: 10, 11, 56, 23 and 99

## HINT

• Before simulating the above process, first clarify the idea, think about which values need to be recorded, whether to use an array, what the control conditions of the loop are, etc.

• about   100%100%   Data, 2 ≤ n ≤ 1052 ≤ n ≤ 105  ， 2≤k≤1002≤k≤100  ， 0≤x≤1000≤x≤100

AUTHOR: toush1

```#include <stdio.h>
int max;
int min;
int tem;
int main()
{
int n, k, i, pos, first, max_num, min_num;
//-----------Enter parameters and all grades and initialize--------------
scanf("%d%d", &n, &k);
for (i = 1; i <= n; i++)
{
min[i] = 101;
max[i] = -1;
}
for (i = 1; i <= n; i++)
scanf("%d", &tem[i]);
//------------Shift Division: cycle when the number of temporary shifts is greater than or equal to k-----------
max_num = 1;
min_num = 1;
while (n >= k)
{
i = 0;
for (first = 1; n - first >= k; first += k)//Find k at a time (k in a group)
{
for (i = 0; i < k; i++)
{
if (tem[first + i] > max[max_num])
max[max_num] = tem[first + i];
if (tem[first + i] < min[min_num])
min[min_num] = tem[first + i];
}
max_num++;
min_num++;
}
//---------------Divide the rest of the temporary class into the last class-------------
if (n - first + 1 == k )
{
max_num++;
min_num++;
}
for (i = first; i <= n; i++)
{
if (tem[i] > max[max_num - 1])
max[max_num - 1] = tem[i];
if (tem[i] < min[min_num - 1])
min[min_num - 1] = tem[i];
}
//---------------Change the highest shift into a temporary shift and clear the highest shift---------------
for (i = 1; i <= max_num - 1; i++)
{
tem[i] = max[i];
max[i] = -1;
}
n = max_num - 1;//n = 3
max_num = 1;
i = 0;
}
//-----------------Divide the remaining people in the last temporary class into the new class and take the lowest score----------------
for (i = 1; i <= n; i++)
{
if (tem[i] < min[min_num])
min[min_num] = tem[i];
}
for (i = 1; i <= min_num; i ++)
printf("%d\n", min[i]);
return 0;
}```

Posted on Wed, 13 Oct 2021 08:53:08 -0400 by bios