CF191E.Thwarting Demonstrations

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It is dark times in Berland. Berlyand opposition, funded from a neighboring state, has organized a demonstration in Berland capital Bertown. Through the work of intelligence we know that the demonstrations are planned to last for kk days.

Fortunately, Berland has a special police unit, which can save the country. It has exactly nn soldiers numbered from 11 to nn . Berland general, the commander of the detachment, must schedule the detachment's work in these difficult kk days. In each of these days, the general must send a certain number of police officers to disperse riots. Since the detachment is large and the general is not very smart, he can only select a set of all soldiers numbered from ll to rr , inclusive, where ll and rr are selected arbitrarily.

Now the general has exactly two problems. First, he cannot send the same group twice — then soldiers get bored and they rebel. Second, not all soldiers are equally reliable. Every soldier has a reliability of aia_{i} . The reliability of the detachment is counted as the sum of reliabilities of soldiers in it. The reliability of a single soldier can be negative, then when you include him in the detachment, he will only spoil things. The general is distinguished by his great greed and shortsightedness, so each day he sends to the dissolution the most reliable group of soldiers possible (that is, of all the groups that have not been sent yet).

The Berland Government has decided to know what would be the minimum reliability of the detachment, sent to disperse the demonstrations during these kk days. The general himself can not cope with such a difficult task. Help him to not embarrass himself in front of his superiors!

输入格式

The first line contains two integers nn and kk — the number of soldiers in the detachment and the number of times somebody goes on duty.

The second line contains nn space-separated integers aia_{i} , their absolute value doesn't exceed 10910^{9} — the soldiers' reliabilities.

Please do not use the %lld specifier to read or write 64-bit integers in С++, it is preferred to use cin, cout streams of the %I64d specifier.

输出格式

Print a single number — the sought minimum reliability of the groups that go on duty during these kk days.

输入输出样例

  • 输入#1

    3 4
    1 4 2
    

    输出#1

    4
    
  • 输入#2

    4 6
    2 -1 2 -1
    

    输出#2

    1
    
  • 输入#3

    8 10
    1 -2 3 -4 5 -6 7 -8
    

    输出#3

    2
    
首页