## CCC '17 S3 - Nailed It!

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
##### Canadian Computing Competition: 2017 Stage 1, Junior #5, Senior #3

Tudor is a contestant in the Canadian Carpentry Challenge (CCC). To win the CCC, Tudor must demonstrate his skill at nailing wood together to make the longest fence possible using boards. To accomplish this goal, he has pieces of wood. The piece of wood has integer length .

A board is made up of exactly two pieces of wood. The length of a board made of wood with lengths and is . A fence consists of boards that are the same length. The length of the fence is the number of boards used to make it, and the height of the fence is the length of each board in the fence. In the example fence below, the length of the fence is 4; the height of the fence is 50; and, the length of each piece of wood is shown:

Tudor would like to make the longest fence possible. Please help him determine the maximum length of any fence he could make, and the number of different heights a fence of that maximum length could have.

#### Input Specification

The first line will contain the integer .
The second line will contain space-separated integers .

For 5 of the 15 available marks, .
For an additional 4 of the 15 available marks, .
For an additional 3 of the 15 available marks, .

#### Output Specification

Output two integers on a single line separated by a single space: the length of the longest fence and the number of different heights a longest fence could have.

4
1 2 3 4

2 1

#### Explanation for Sample Output 1

Tudor first combines the pieces of wood with lengths and to form a board of length .
Then he combines the pieces of wood with lengths and to form another board of length .
Finally, he combines the boards to make a fence with length and height .

#### Sample Input 2

5
1 10 100 1000 2000

1 10

#### Explanation for Sample Output 2

Tudor can't make a fence longer than length , and there are ways to make a fence with length by choosing any two pieces of wood to nail together.
Specifically, he may have a fence of height , , , , , , , , and .

## Comments

• commented on Jan. 23, 2024, 4:20 p.m.

what a tricky question

• commented on Sept. 2, 2022, 5:51 p.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on May 23, 2021, 5:29 p.m. edited

Are all lengths of the pieces of wood distinct?

Edit: Thanks.

• commented on May 23, 2021, 9:39 p.m.

No.

• commented on Jan. 14, 2021, 6:03 a.m.

I'm tryna check which test case my code fails on but I don't know which one it is cuz test data isn't properly numbered. Is there a way I can find out what subtask 1 test 2 is in the input files ?

• commented on May 17, 2021, 12:43 p.m.

I suppose you can go to the offical CEMC website and find all the test data there. Then just manually check through the however many test case there are.

• commented on Sept. 2, 2022, 5:26 p.m.

But you should try to solve it yourself first because in the actual CCC you don't have the test data available.

• commented on Jan. 14, 2018, 1:54 a.m.

This comment is hidden due to too much negative feedback. Show it anyway.

• commented on Jan. 14, 2018, 8:42 p.m.

Problem testcases are weighted out of 15.