CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » January Cook-Off » Makx Sum

Makx Sum

Problem code: KSUBSUM

  • All Submissions

All submissions for this problem are available.

Did you know that the Hindus believe there are 330 million deities ? Lets discuss about them in long contests. The three main forces of god Brahma, Vishnu and Mahesh, also called Trimurti ( 3 forms ), want to decide when to end the world. Given an array A, which contains the 'Good' ( or 'Evil' ) score of each place on earth, they can easily find the maximum sum of the scores of a (contiguous) sub-array of places. But this is not much useful to them. So, each of them gives a value K and want to know the Kth maximum sum of scores of a contiguous sub-array. In other words, find the value of S[K] (1-based index), where the array S contains the sums of all possible contiguous sub-arrays in non-increasing order.

Input

First line contains T, number of test cases. T cases follow. In each test case, first line contains N K1 K2 K3. Next line contains N space separated integers.

Output

For each test case, output the K1th, K2th and K3th maximum sum in a single line, separated by a single space. See sample cases and explanation for more clarity.

Constraints

1 ? T ? 3
2 ? N ? 10000
1 ? K1 < K2 < K3 ? 2012
K3 ? N*(N+1)/2
-10000 ? A[i] ? 10000

Example

Input:
3
3 1 2 3
10 20 30
3 3 4 6
10 20 30
4 2 6 10
20 -15 10 -15

Output:
60 50 30
30 30 10
15 -5 -20

Explanation:
Case 1 & 2 : A = { 10, 20, 30 }. All possible sums of sub-arrays in non-increasing order, S[1..6] = { 60, 50, 30, 30, 20, 10 }


Warning : "Large input / output. Be careful with certain languages. Eg: Prefer using scanf/printf to cin/cout for C++"

Note : There are multiple test sets, and the judge shows the sum of the time taken over all test sets of your submission, if Accepted.


Author: flying_ant
Date Added: 9-01-2012
Time Limit: 3 sec
Source Limit: 50000 Bytes
Languages: ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

In the explanation, why is

kewljerk @ 22 Jan 2012 09:40 PM
In the explanation, why is 30+10=40 case is not there??

@admin : Why am i being shown

nitishkr @ 22 Jan 2012 09:54 PM
@admin : Why am i being shown a runtime error ??

@kewljerk : The subarray

anil_adm @ 22 Jan 2012 09:58 PM
@kewljerk : The subarray should be *contiguous* @nitishkr : It may be due to various reasons. Go through the FAQ page.. we do not encourage such questions during the match

A newbie here. Can anyone

moawalling @ 22 Jan 2012 10:30 PM
A newbie here. Can anyone tell how many initial different arrays are given?

@moawalling : Each test case

anil_adm @ 22 Jan 2012 10:34 PM
@moawalling : Each test case will contain only one array and there can be T such test cases. For this problem 1 <= T <= 3. Please read the 'Input' section again.

Still can't find out mistake

nitishkr @ 22 Jan 2012 10:37 PM
Still can't find out mistake ! Please Help .

@nitishkr : Please do not ask

anil_adm @ 22 Jan 2012 10:42 PM
@nitishkr : Please do not ask such questions during a live contest. If you are stuck, you may move to others problems and try this later.

@admin Why does it show

flareneos @ 22 Jan 2012 11:20 PM
@admin Why does it show SIGABRT ? Pls answer

i am not getting the pattern

saurabhzx @ 22 Jan 2012 11:27 PM
i am not getting the pattern of subarrays..will u plz provide one more example regarding this....

http://www.codechef.com/wiki/

anil_adm @ 22 Jan 2012 11:29 PM
http://www.codechef.com/wiki/faq#Why_do_I_get_a_SIGABRT

@saurabzx : The contest is

anil_adm @ 22 Jan 2012 11:30 PM
@saurabzx : The contest is still live, we do not provide additional sample cases now.

Is there any way to test this

suhendry @ 23 Jan 2012 12:06 AM
Is there any way to test this problem after contest?

@suhendry: The problems has

admin @ 23 Jan 2012 07:37 AM

@suhendry: The problems has been moved into the practice section. You can submit your solutions there.

plz tell me why i am getting

deepak_nitk @ 23 Jan 2012 12:08 PM
plz tell me why i am getting runtime error(SIGSEGV) while my program:806062 is running fine on my machine

@admin: how can i verify my

codechampion @ 25 Jan 2012 12:58 PM
@admin: how can i verify my solution? I didnt participate in the competition.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com