<s>求_v 大佬_n 设计_v 一下_m 程序_n ，_w 我_r 的_u 时间_n 复杂度_n 太_d 大_a 了_y</s>
<s>这_r 种_q 题目_n 真_d 讨厌_v 啊_y ~~_w 语文_n 不_d 好_a ，_w 要_v 看_v 半天_m 才_d 能_v 看懂_v 他_r 在_d 说_v 什么_r 。_w</s><s>分析_v 题目_n ，_w 结果_n 如下_v ：_w 有_v 一_m 个_q 长度_n 为_v n_nx 的_u 数_n 组_n ，_w 起始_vn 位置_n 是_v 数_n 组_n 头部_n pos_nx =_w 0_m ；_w 每_r 轮_q 可以_v 跳_v x_nx 步_q (_w 1_m <_w =_w x_nx <_w =_w Vi_nx )_w 同时_c 需_v 满足_v （_w Di_nx >_w =_w n_nx [_w pos_nx +_w x_nx ]_w ）_w ；_w 经过_p 若干_m 轮_q 后_f ，_w 判断_v 最后_f 是否_v 能_v 到达_v 数_n 组_n 尾部_f pos_nx =_w n_nx -_w 1_m 。_w</s><s>给定_v m_nx 个_q （_w Vi_nx ，_w Di_nx ）_w ，_w 判断_v 每_r 个_q 是否_v 能_v 到达_v 。_w</s><s>这个_r 用_p 贪婪_a 算法_n ，_w 每_r 次_q 能_v 跳_v 多_d 远_a 就_d 跳_v 多_d 远_a ，_w 如果_c 一_m 步_q 都_d 不_d 能_v 跳_v 那么_c 就_d 一定_d 跳_v 不_d 出_v 了_y 。_w</s><s>这个_r 问题_n 时间_n 复杂度_n O_nx (_w n_nx )_w ~_w #_q include_nx <_w stdio_nx ._w h_nx >_w #_q include_nx <_w stdlib_nx ._w h_nx >_w int_nx main_nx (_w )_w {_w int_nx n_nx ,_w m_nx ,_w pos_nx ,_w step_nx ;_w int_nx *_w pool_nx ,_w *_w Vi_nx ,_w *_w Di_nx ;_w scanf_nx (_w "_w %_w d_nx %_w d_nx "_w ,_w &_w n_nx ,_w &_w m_nx )_w ;_w /_w /_w 读_v 入_v 长度_n 为_v n_nx 的_u 鳄鱼_n 数据_n pool_n =_w (_w int_nx *_w )_w malloc_n (_w sizeof_nx (_w int_nx )_w *_w n_nx )_w ;_w for_v (_w int_nx i_nx =_w 0_m ;_w i_nx <_w n_nx ;_w i_nx +_w +_w )_w scanf_nx (_w "_w %_w d_nx "_w ,_w pool_nx +_w i_nx )_w ;_w /_w /_w 读_v 入_v m_nx 个_q 装备_n 的_u 属性_n Vi_nx =_w (_w int_nx *_w )_w malloc_nx (_w sizeof_nx (_w int_nx )_w *_w m_nx )_w ;_w Di_nx =_w (_w int_nx *_w )_w malloc_nx (_w sizeof_nx (_w int_nx )_w *_w m_nx )_w ;_w for_v (_w int_nx i_nx =_w 0_m ;_w i_nx <_w m_nx ;_w i_nx +_w +_w )_w scanf_nx (_w "_w %_w d_nx %_w d_nx "_w ,_w Di_nx +_w i_nx ,_w Vi_nx +_w i_nx )_w ;_w /_w /_w 求_v 每_r 个_q 装备_n 是_v 能_v 渡过_v for_v (_w int_nx i_nx =_w 0_m ;_w i_nx <_w m_nx ;_w i_nx +_w +_w )_w {_w pos_nx =_w 0_m ;_w /_w /_w 起始_vn 位置_n while_nx (_w pos_nx <_w n_nx -_w 1_m )_w {_w step_nx =_w 0_m ;_w /_w /_w 求_v 一_m 次_q 最多_d 能_v 跳_v 几_m 步_q for_v (_w int_nx j_nx =_w 1_m ;_w j_n <_w =_w Vi_n [_w i_nx ]_w &_w &_w pos_nx +_w j_n <_w n_nx ;_w j_nx +_w +_w )_w if_r (_w Di_nx [_w i_nx ]_w >_w =_w pool_n [_w pos_nx +_w j_n ]_w )_w step_n =_w j_nx ;_w /_w /_w 如果_c 一_m 步_q 都_d 跳_v 不_d 了_v ，_w 那_c 就_d 不_d 再_d 跳_v 了_u if_r (_w step_nx =_w =_w 0_m )_w break_nx ;_w else_r pos_nx +_w =_w step_nx ;_w }_w /_w /_w 输出_vn 结果_n if_r (_w pos_nx =_w =_w n_nx -_w 1_m )_w printf_nx (_w "_w Yes_r \_w n_n "_w )_w ;_w else_r printf_nx (_w "_w No_m \_w n_nx "_w )_w ;_w }_w free_nx (_w pool_n )_w ;_w free_nx (_w Vi_nx )_w ;_w free_n (_w Di_nx )_w ;_w }_w</s>
