Positioning Peter’s Paintings | 프로그래밍의 벗 PivotOJ
PivotOJ

Positioning Peter’s Paintings

시간 제한: 2000ms메모리 제한: 2048MB출처: CCC 2025 SeniorBOJ 34466

문제

Peter the painter just finished painting two rectangular paintings and would like to display both on a rectangular wall which has the smallest perimeter possible. The first painting has a base of length AA units and a height of length BB units. The second painting has a base of length XX units and a height of length YY units.

Peter has a few conditions on how to arrange his paintings on the rectangular wall. The first condition is that the paintings must be upright, meaning that the bases of the paintings are parallel to the floor. The second condition is that he would like to display both paintings in full, meaning that they cannot overlap each other. Please help determine the rectangular wall of minimum perimeter such that the paintings can be displayed without violating his conditions.

입력

The one line of input will consist of four space-separated positive integers, AA, BB, XX, YY (1 ≤ A, B, X, Y ≤ 10^8).

출력

Output a single integer representing the minimum perimeter of a rectangular wall without violating Peter’s conditions.

예제

예제 1

입력
3 3 3 3
출력
18

예제 2

입력
2 2 4 4
출력
20

예제 3

입력
1 2 3 1
출력
12
코드를 제출하려면 로그인하세요.