E. Sleeping Schedule

Vova面临一个关于睡眠安排的问题,他需要在一天内睡n次,每次睡h小时。如果他在l到r(包括l和r)的时间范围内开始睡觉,那么这次睡眠就被认为是优质的。Vova可以选择在第ii次睡眠前a_i或a_i-1小时开始。任务是确定Vova最多可以有多少次优质睡眠。给定n, h, l, r和一系列的a_i,需要找出最优策略并输出最大优质睡眠次数。" 135040541,7337247,人工智能与云计算:变革技术的应用与原理,"['AI', '深度学习', '云计算', '机器学习', '自然语言处理']
摘要由CSDN通过智能技术生成

链接:https://codeforces.ml/contest/1324/problem/E

Vova had a pretty weird sleeping schedule. There are hh hours in a day. Vova will sleep exactly nn times. The ii-th time he will sleep exactly after aiai hours from the time he woke up. You can assume that Vova woke up exactly at the beginning of this story (the initial time is 00). Each time Vova sleeps exactly one day (in other words, hh hours).

Vova thinks that the ii-th sleeping time is good if he starts to sleep between hours ll and rr inclusive.

Vova can control himself and before the ii-th time can choose between two options: go to sleep after aiai hours or after ai−1ai−1 hours.

Your task is to say the maximum number of good sleeping times Vova can obtain if he acts optimally.

Input

The first line of the input contains four integers n,h,ln,h,l and rr (1≤n≤2000,3≤h≤2000,0≤l≤r<h1≤n≤2000,3≤h≤2000,0≤l≤r

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值