Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Unique Solution
Description 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: Input 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 Output exactly one line for each test case. Output Yes if the answer is in the affirmative otherwise No. Sample Input 5 2 3 -2 3 -2 4 5 2 3 -2 3 -12 4 0 0 Sample Output No Yes Source POJ Monthly--2006.07.30, Wang, Yijie |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator