| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 | 1024 MB | 103 | 72 | 66 | 70.213% |
Your next-door neighbor has asked to borrow some fencing to put around all of his land. Being the kind neighbor that you are, you’ve decided to lend him your fencing. But being the stingy farmer that you are, you’ve also decided to give him exactly enough, and no more. An interesting quality of your neighbor’s farm is that it’s shaped like a histogram. Given the width and height of each column of the histogram, determine the perimeter of your neighbor’s land.
The first line will contain a single integer n that indicates the number of data sets that follow. Each data set will start with a single integer x denoting the number of ‘bars’ in your neighbor’s histogram shaped plot of land. The next two lines consists of x space separated integers each, representing the widths and heights respectively of each bar of land.
For each test case, output the amount of fencing needed to surround the perimeter of your neighbors histogram shaped plot of land.
2 7 1 1 1 1 1 1 1 1 3 6 3 3 3 2 3 1 2 3 1 2 3
26 18
School > PLU High School Programming Contest > PLU 2017 > Advanced 12번