Please do not give solution in image formate thanku. There were N students that decided to go on a camping trip. They found a suitable place for camping with a width of one meter and a length of 200 meters, knowing that their tents are 1 by 1 meter.   They decided to build a rectangular fence and camp inside it. However every person i is satisfied if the sum of the two distances between his tent and the tent before and after him is atleast Xi(subscript) It is given that the first tent does not have a tent before it. So it's occupant is satisfied if the sum of the two distances between his tent and the tent after it and the fence before it is atleast Xi. Similarly the occupant of the last tent is satisfied if the sum of the distances between his tent and the tent before it and the fence after it is atleast Xi.   Your task is to find the smallest possible perimeter for the fence. Input: The first line contains an Integer N denoting the number of elements in X. Each line i of the N subsequent lines contains an integer describing Xi Constraints: 1≤N≤20 0≤X[i]≤7   Sample input: 2 2 1 Output: 10 We put the first tent at co-ordinate 1 and the second at coordinate 4. So the length of the fence is 4 and the perimeter is 10. Sample input: 3 1 1 2 Output: 12 We put the first tent at coordinate 1 and the second at coordinate 5 and the third at coordinate 3 so that the length of the fence is 5 and the perimeter is 12. Sample Input: 4 0 1 2 3 Output: 16

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please do not give solution in image formate thanku.

There were N students that decided to go on a camping trip. They found a suitable place for camping with a width of one meter and a length of 200 meters, knowing that their tents are 1 by 1 meter.

 

They decided to build a rectangular fence and camp inside it. However every person i is satisfied if the sum of the two distances between his tent and the tent before and after him is atleast Xi(subscript)

It is given that the first tent does not have a tent before it. So it's occupant is satisfied if the sum of the two distances between his tent and the tent after it and the fence before it is atleast Xi. Similarly the occupant of the last tent is satisfied if the sum of the distances between his tent and the tent before it and the fence after it is atleast Xi.

 

Your task is to find the smallest possible perimeter for the fence.

Input:

The first line contains an Integer N denoting the number of elements in X.

Each line i of the N subsequent lines contains an integer describing Xi

Constraints:

1≤N≤20

0≤X[i]≤7

 

Sample input:

2

2

1

Output:

10

We put the first tent at co-ordinate 1 and the second at coordinate 4. So the length of the fence is 4 and the perimeter is 10.

Sample input:

3

1

1

2

Output:

12

We put the first tent at coordinate 1 and the second at coordinate 5 and the third at coordinate 3 so that the length of the fence is 5 and the perimeter is 12.

Sample Input:

4

0

1

2

3

Output:

16

Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY