Submit | All submissions | Best solutions | Back to list |
ABA12E - Shooting the balloons! |
Dhinakaran is very fond of games. Shooting the balloons is his favourite. In this game, there are ‘n’ balloons which are arranged in a line. Every balloon has a unique number which is the number of points earned if that balloon is shot. A constraint here is that you should shoot contiguous balloons. So, Dhinakaran wanted to find the maximum number of points he could earn. He sought help from a friend who told him that it was the famous maximum contiguous sum problem. So Dhinakaran learnt about it and was happy. But Dhinakaran is not someone who gets satisfied so easily. He wanted to find the k-th smallest possible contiguous sum! Now, his friend was not able to solve this. So he came to me. I suggested that he approach you. You are a great coder, aren’t you? Help him out.
There will be at least 1 balloon and at most 50000 balloons, and each balloon can have at least 0 point and at most 109 points.
Input
The first line of each data set contains the number of balloons and value of k.
1 <= k <= (n * (n + 1)) / 2
The second line contains N space separated integers.
Output
The output for each test case should be a single line containing the k-th smallest possible contiguous sum of points that could be achieved.
Example
Input: 5 3 1 2 3 4 5 Output: 3
Explanation of Sample Case
The first 5 smallest contiguous subsequences are 1, 2, 3, 1 + 2, 4
Added by: | Kashyap Krishnakumar |
Date: | 2012-01-15 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own problem |
hide comments
2022-06-29 16:20:22
Best problem on binary search |
|
2019-09-06 15:34:09
how is this problem done |
|
2019-02-14 10:33:09
How many data sets does this provide? |
|
2015-01-14 14:37:45 (Tjandra Satria Gunawan)(曾毅昆)
warning: input is badly formated |
|
2015-01-14 13:34:35 (Tjandra Satria Gunawan)(曾毅昆)
Yes ballon can have 0 points, It cost me 2 WA. Thank you abhiranjan for your report. Problem description has been updated. |
|
2012-05-27 07:30:04 abhiranjan
Correction: ...and each balloon can have atleast |
|
2012-05-23 08:23:05 Teddy Budiono Hermawan
N is the number of balloons. There will be atleast 1 balloon and atmost 50000 balloons |
|
2012-03-26 21:53:59 Rahul Bobhate
What is the range of n ? |