当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。
Given N (1 ≤ N ≤ 1,000) integers a1, a2, …, aN (|ai| ≤ 100,000, 1 ≤ i ≤ N) and an integer M (1 ≤ M ≤ N), you are to determine whether there exists a unique set of 2M integers s1, e1, s2, e2, …, sM, eM (1 ≤ s1 ≤ e1 < s2 ≤ e2 < ... < sM ≤ eM ≤ N) such that the following sum is maximized:
__poj_jax_start__\sum_{i=1}^M\sum_{j=s_i}^{e_i}a_j__poj_jax_end__
The input contains multiple test cases. Each test case contains consists of two lines. The first line gives the integers N and M. The second line gives the integers a1, a2, …, aN.
A pair of zeroes indicates the end of the input and should not be processed.
Output exactly one line for each test case. Output Yes if the answer is in the affirmative otherwise No.
5 2 3 -2 3 -2 4 5 2 3 -2 3 -12 4 0 0
No Yes
时间上限 | 内存上限 |
1000 | 131072 |