Cho n túi kẹo, túi thứ i có ai viên. Hãy chia các túi này thành hai phần sao cho số viên kẹo chênh lệch giữa hai phần là nhỏ nhất Ví dụ: Cho 7 túi có số viên kẹo trong từng túi lần lượt là: 30, 25, 40, 20, 26, 30, 20. Sau khi chia thành 2 phần để có số viên kẹo chênh lệch giữa 2 phần nhỏ nhất ta được kết quả: Phần thứ nhất:30 + 25 + 40 = 95 Phần thứ hai:20 + 26 + 30 + 20 = 96 Vậy số viên chênh lệch nhỏ nhất là: 96 –95 = 1 Dữ liệu vào:Cho file CHIAKEO.INP gồm: -Dòng đầu tiên chứa số n là số lượng các túi kẹo. -n dòng tiếp theo, dòng thứ i chứa số viên của túi kẹo thứ i. Kết quả: Ghi ra file CHIAKEO.OUT một số nguyên là số viên chênh lệch nhỏ nhất.

Các câu hỏi liên quan

Rebecca Stevens was the first woman to climb Mount Everest. Before she went up the highest mountain in the world, she was a journalist and lived in South London. In 1993, Rebecca left her job and her family and travelled to Asia with some other climbers. She found that life on Everest is very difficult. “ You must carry everything on your back, “ she explained, “ so you can only take things that you will need. You can’t wash on the mountain, and in the end I didn’t even take a toothbrush. I am usually a clean person but there is no water, only snow. Water is very heavy so you only take enough to drink!” Rebecca became famous when she reached the top of Mount Everest on May 17, 1993. After that, she wrote a book about the trip and people often asked her to talk about it. She got a new job too, on science programme on television. 36. Where was Rebecca Stevens from? A. England B. Asia C. Everest D. The South 37. Before she climbed Everest, Rebecca Stevens was a.................. . A. climber B. journalist C. traveller D. scientist 38. Why did Rebecca Stevens become famous? A. She left her job and her family and travelled to Asia. B. She found that life on Everest is very difficult. C. She reached the top of Mount Everest in 1993. D. She was the first woman to climb Mount Everest. 39. Life on Everest is very difficult because................. A. it is very high B. you can’t take anything with you C. there is no water there D. there are no toothbrushes 40. After 1993, Rebecca had a................ . A. new book B. new job C. programme D. television