CF1324E Sleeping Schedule

题目描述

Vova有个非常奇怪的睡眠日程表。一天有$h$个小时,Vova将正好睡$n$次觉,从每次刚醒来的那一刻计起,他将在$a_i$小时后睡第$i$次觉。你可以假设Vova在故事开始时是刚醒来的。(初始时间为0)每次Vova正好睡一天(也就是$h$小时)。 如果他在$[l,r]$时间段内开始睡觉,便认为这一次睡眠是优秀的。 Vova可以控制自己,在第$i$次睡眠前,选择在$a_i$或$a_i-1$小时后开始睡觉。 你的任务是计算出优秀睡眠次数的最大值。

输入格式

输出格式

说明/提示

The maximum number of good times in the example is $ 3 $ . The story starts from $ t=0 $ . Then Vova goes to sleep after $ a_1 - 1 $ hours, now the time is $ 15 $ . This time is not good. Then Vova goes to sleep after $ a_2 - 1 $ hours, now the time is $ 15 + 16 = 7 $ . This time is also not good. Then Vova goes to sleep after $ a_3 $ hours, now the time is $ 7 + 14 = 21 $ . This time is good. Then Vova goes to sleep after $ a_4 - 1 $ hours, now the time is $ 21 + 19 = 16 $ . This time is not good. Then Vova goes to sleep after $ a_5 $ hours, now the time is $ 16 + 20 = 12 $ . This time is not good. Then Vova goes to sleep after $ a_6 $ hours, now the time is $ 12 + 11 = 23 $ . This time is good. Then Vova goes to sleep after $ a_7 $ hours, now the time is $ 23 + 22 = 21 $ . This time is also good.