ÀÂÒ
Language: Russian
English

Remote Training on Programming

Problems Online status Contests
News FAQ E-learning
For authors:
Register  ||  Login
 
Hello, Guest! Please login or register.

1182. Heap of stones - 3

Time Limit: 1 seconds
Memory Limit:128000KB
Points:100
View Problem Statistics Submit Problem added Èãîðü Àíäðèàíîâ

There are N stones of different weights. It is required to divide them on two heaps so that weight of heaps were as much as possible close to each other.

Input. First line contains natural number N (1<=N<=40). Next line contains N integer numbers wi - weights of stones (1<=wi<=10^8), separated by spaces.

Output. Minimal absolute value of a difference of weights of heaps.

Example.

Input

Output

4

1 5 2 3

1

 

 


View Problem Statistics Submit Problem discussion Author/source:
Educational Courses / Algorithms and Data Structures / Enumeration, Dynamic Programming, Greedy algs /
2154. Heap of Stones - 2 1182. 1493. How to Get One 1336. How to Get One-1 2142. Knapsack - 1
Problems from Contests and Camps / Trainings of Vologda SU / Elective course on algorithms, final exercise 2012 /
1184. C - Game with chips 1182. 558. E - Hottabich and Garland 1183. F - Chains of contacts
time generating 0.109 sec.
© Copyright VSU, AVT, Nosov D.A., Andrianov I.A.