Can Anyone Provide A Efiifcient method to solve this question

Create two sub array of maximum equal height from an array.
Problem Statement:

There are N bricks (a1, a2, ...., aN). Each brick has length L1, L2, ...., LN). Make 2 highest parallel pillars (same length pillars) using the bricks provided.

Constraints:

There are N bricks. 5<=N<=50
Length of each brick. 1<=L<=1000
Sum of the bricks lengths <= 1000
Length of the bricks is not given in size order. There may be multiple bricks which may have the same length. Not all bricks have to be used to create the pillars.

Example:

1st Example-
N = 5
2, 3, 4, 1, 6
Possible Sets:
(2, 6) and (3, 4, 1)
Answer: 8

2nd Example-
N = 6
1, 5, 1, 6, 1, 1
Possible Sets:
(6, 1) and (1, 5, 1)
Answer: 7
Efficient with regard to what? Time taken to run? Memory usage? CPU usage? Lines of code?

"Efficient" on its own is meaningless.

(As with most of these codechef cheaters, I suspect the answer is really "Efficient with regards to me doing the least amount of work I can get away with, while other people do it all for me.)
Last edited on
efficient with respect to time. In minimum time complexity.
i just saw this question on Net, so i asked how to solve this question with respect to minimum time Complexity.
and also this not a Codechef question.
Topic archived. No new replies allowed.