Logo
(追記) (追記ここまで)

26544번 - Histogram Fencing 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB103726670.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.

제한

예제 입력 1

2
7
1 1 1 1 1 1 1
1 3 6 3 3 3 2
3
1 2 3
1 2 3

예제 출력 1

26
18

힌트

출처

School > PLU High School Programming Contest > PLU 2017 > Advanced 12번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /