There are N heaps of sweets (numbered 1 through N); for each valid i, the i-th of them contains exactly ik sweets. You aim to partition these heaps between you and your friend in such a way that each...


There are N heaps of sweets (numbered 1 through N); for each valid i, the i-th of<br>them contains exactly ik sweets. You aim to partition these heaps between you and<br>your friend in such a way that each heap is given to exactly one of you without<br>being split among you.<br>The distribution should be as fair as possible. Formally, let's denote the total<br>number of sweets you get by A and the total number of sweets your friend gets by<br>B; your goal is to minimise JA-BJ.<br>Develop a python code to find the smallest possible value of JA-BJ.<br>Sample Input:<br>2<br>1<br>4<br>Sample Output:<br>2<br>0001<br>

Extracted text: There are N heaps of sweets (numbered 1 through N); for each valid i, the i-th of them contains exactly ik sweets. You aim to partition these heaps between you and your friend in such a way that each heap is given to exactly one of you without being split among you. The distribution should be as fair as possible. Formally, let's denote the total number of sweets you get by A and the total number of sweets your friend gets by B; your goal is to minimise JA-BJ. Develop a python code to find the smallest possible value of JA-BJ. Sample Input: 2 1 4 Sample Output: 2 0001

Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here