DMOPC '18 Contest 4 P2 - Dr. Henri and Responsibility

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Python 2.5s
Memory limit: 64M
Python 128M

Author:
Problem type

Dr. Henri is a very busy person. He has N responsibilities to attend to over the next two days. Being a very organized person, he wants to split the tasks evenly between the two days. More specifically, if the tasks on day 1 take t1 seconds, and the tasks on day 2 take t2 seconds, he wants to minimize the value of |t1t2|.

The ith task takes him Ai seconds, and must be completed within a single day. Dr. Henri, being very busy with these tasks, then asks you: what is the minimum value of |t1t2| if he partitions his tasks optimally?

Constraints

0Ai700

Subtask 1 [20%]

1N20

Subtask 2 [80%]

1N700

Input Specification

The first line of input will contain a single integer, N.
The next and final line of input will contain N space separated integers: A1,A2,,AN.

Output Specification

Output the minimum value of |t1t2| if Dr. Henri partitions the tasks optimally.

Sample Input

Copy
6
4 2 3 1 1 1

Sample Output

Copy
0

Explanation for Sample Output

If he partitions the task as {2,3,1} and {4,1,1}, they both sum to 6, and thus the difference is 0.


Comments


  • 15
    discoverMe  commented on Jan. 17, 2019, 7:31 p.m.

    note 1 day does not limited to 86400 seconds