4 Adjacent Stick Game Mukesh and friends have set out on a vacation to Coorg. They have booked accommodation in a resort and the
4 Adjacent Stick Game Mukesh and friends have set out on a vacation to Coorg. They have booked accommodation in a resort and the resort authorities organize Camp fires every night as a part of their daily activities. Mukesh volunteered himself for an activity called the "Adjacent Stick Game" where sticks of different length will be placed in a line and Mukesh needs to remove a stick from each adjacent pair of sticks. He then has to form a bigger stick by combining all the remaining sticks. Mukesh needs to know the smallest length of the bigger stick so formed and needs your help to compute the same. Given the number of sticks N and the lengths of each of the sticks, write a program to find the smallest length of the bigger stick that is formed. Input Format First line of input contains an integer N denoting the number of sticks. Assume that the maximum value for N as 50. Assume that N is always even. Next line of input contains an N integer denoting the length of each of the sticks. Output Format Output the smallest length of the bigger stick that is formed. Sample Testcases Testcase 1 Input Testcase 1 Output 2 13 1 Testcase 2 Input 4 4235 2 Testcase 2 Output 5
Step by Step Solution
There are 3 Steps involved in it
Step: 1
To solve this problem you need to find the smallest length of the bigger stick that is formed by rep...See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started