<s>PAT_n 乙_Mg 级_n 1030_m ._m</s><s>完美_a 数列_n (_w 25_m )_w</s>
<s>#_q include_nx <_w stdio_nx ._w h_nx >_w #_q include_nx <_w stdlib_nx ._w h_nx >_w int_nx sort_nx __w function_nx (_w const_nx void_n *_w a_nx ,_w const_nx void_n *_w b_nx )_w {_w return_nx *_w (_w (_w double_nx *_w )_w a_nx )_w -_w *_w (_w (_w double_nx *_w )_w b_nx )_w ;_w }_w int_nx main_nx (_w )_w {_w int_nx N_nx ,_w i_nx ,_w j_nx ,_w sum_nx =_w 0_m ;_w double_v p_nx ,_w *_w a_nx ;_w scanf_nx (_w "_w %_w d_nx %_w lf_nx "_w ,_w &_w N_nx ,_w &_w p_nx )_w ;_w a_nx =_w (_w double_nx *_w )_w malloc_nx (_w sizeof_nx (_w double_nx )_w *_w N_nx )_w ;_w if_nx (_w !_w a_nx )_w {_w fprintf_nx (_w stderr_nx ,_w "_w malloc_nx error_nx !_w \_w n_nx "_w )_w ;_w return_nx -_w 1_m ;_w }_w for_v (_w i_nx =_w 0_m ;_w i_nx <_w N_nx ;_w i_r +_w +_w )_w scanf_nx (_w "_w %_w lf_nx "_w ,_w &_w a_nx [_w i_nx ]_w )_w ;_w qsort_nx (_w a_nx ,_w N_nx ,_w sizeof_nx (_w double_nx )_w ,_w sort_nx __w function_nx )_w ;_w for_v (_w i_nx =_w 0_m ;_w i_n <_w N_nx ;_w i_nx +_w +_w )_w {_w for_v (_w j_n =_w N_nx -_w 1_m ;_w j_nx >_w 0_m ;_w j_nx -_w -_w )_w {_w if_r (_w a_nx [_w j_n ]_w <_w =_w a_nx [_w i_nx ]_w *_w p_nx )_w {_w if_r (_w sum_nx <_w j_n -_w i_nx )_w sum_nx =_w j_nx -_w i_nx ;_w else_nx break_nx ;_w }_w }_w }_w printf_nx (_w "_w %_w d_nx \_w n_nx "_w ,_w sum_nx +_w 1_m )_w ;_w free_nx (_w a_nx )_w ;_w return_nx 0_m ;_w }_w 栈_Ng 上_f 的_u 空间_n 是_v 有限_a 的_u ，_w 不_d 建议_v 你_r 在_p 栈_Ng 上_f 申请_v 太_d 大_a 的_u 空间_n 。_w</s><s>需要_v 多少_r 就_d 申请_v 过少_r ，_w 但是_c C_nx 语言_n 不_d 支持_v 可变数_n 组_n ，_w 所以_c 在_p 栈_Ng 上_f 申请_v 了_u 空间_n 。_w</s><s>对于_p 缩小_v 运行_vn 时间_n ，_w 从_p 你_r 这个_r 程序_n 里_f 来讲_v ，_w 从_p 减少_v 循环_vn 次数_n 开始_v 吧_y ，_w 若_c 想_v 减少_v 循环_vn 次数_n ，_w 那么_c 就_d 要_v 从_p 算法_n 上_f 考虑_v 了_y 。_w</s>
