#P15097. [ICPC 2025 LAC] Coatless in Yakutsk

    ID: 17015 远端评测题 1500ms 1024MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>贪心二分并查集单调队列2025ICPC

[ICPC 2025 LAC] Coatless in Yakutsk

题目描述

It was your first time visiting Salvador, and you made the rookie mistake of sleeping on the beach. You woke up red, sunburned, and frankly, humiliated. Swearing vengeance against the sun and all its terrible consequences, you decided that your next vacation would be somewhere with a real winter – like Yakutsk, Russia, where the average temperature is 42-42^\circ Celsius.

But you came prepared! You brought a warm, cozy coat. The coat is perfect, it warms you very well. Maybe too well, as you get sweaty and the coat gets dirty after CC days of use. Since your trip lasts more than CC days, you must find a way to avoid walking around smelling bad.

To do so, when the coat gets dirty, you cannot wear it until it is washed, but you may also choose to wash it earlier. On any day you do not wear the coat – whether because it is dirty or being washed – you must endure the day’s temperature without its protection. After being washed, the coat is fresh and ready to be worn again. At the start of your trip, the coat is clean.

Given the daily temperatures in Yakutsk for the duration of your trip, you must determine the lowest temperature on a day when you are forced to be without your coat, assuming you schedule wash days optimally to make this temperature as high as possible.

输入格式

The first line contains two integers CC and NN (1C<N1051 \le C < N \le 10^5), indicating respectively the number of days you can wear the coat before it gets dirty, and the duration in days of your holidays.

The second line contains NN integers T1,T2,,TNT_1, T_2, \dots, T_N (50Ti50-50 \le T_i \le 50 for i=1,2,,Ni = 1, 2, \dots, N), where TiT_i is the temperature on the ii-th day.

输出格式

Output a single line with an integer indicating the minimum temperature you must endure without your coat.

2 6
-20 -10 -5 -10 -2 -40
-5