| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 | 2048 MB | 166 | 111 | 100 | 65.789% |
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 $A$ units and a height of length $B$ units. The second painting has a base of length $X$ units and a height of length $Y$ 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, $A,ドル $B,ドル $X,ドル $Y$ (1ドル ≤ A, B, X, Y ≤ 10^8$).
Output a single integer representing the minimum perimeter of a rectangular wall without violating Peter’s conditions.
3 3 3 3
18
An optimal arrangement using a 6ドル$-by-3ドル$ wall is shown below.
2 2 4 4
20
An optimal arrangement using a 6ドル$-by-4ドル$ wall is shown below.
1 2 3 1
12
An optimal arrangement using a 3ドル$-by-3ドル$ wall is shown below.