#P16556. [ICPC 2026 LAC] Jaime' s Palace
[ICPC 2026 LAC] Jaime' s Palace
题目描述
Churro, a chubby and energetic guinea pig, has just started a new job at a fancy restaurant called Jaime's Palace. Since she is the newest employee, she is only responsible for washing and arranging the plates. Churro discovered that the most efficient way to keep the plates organized and easily accessible for the chef is by storing them in a single stack.
There are plates in Jaime's Palace, and of them are used on the -th day. Churro designed a rigid and highly logical system for managing the plates. On the -th day she takes the top plates from the stack and the chef uses each of them just once during the day. At the end of the day, Churro washes the used plates and places them back on top of the stack in an arbitrary order.
Churro's system is a real success. However, she is curious about the following questions. After repeating the above procedure for days, can she be sure that there is a plate that was used at least times? What is the maximum value of that she can guarantee? Please help Churro to determine that value.
输入格式
The first line contains two integers () and (), indicating respectively the number of plates and the number of days.
The second line contains integers ( for ), where is the number of plates used on the -th day.
输出格式
Output a single line with an integer indicating the maximum value of such that after days and for any reordering of the plates put back into the stack at the end of each day, there is a plate that was used at least times.
10 3
1 1 2
3
10 4
5 3 5 2
3
提示
Explanation of Sample 1:
On each of the first two days, Churro takes the top plate from the stack and places it back on top, so that plate is used twice. On the third day she takes the top two plates, so one of those plates is used three times, independently of the order in which the plates are placed back on top of the stack at the end of the third day.