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

34466번 - Positioning Peter’s Paintings 다국어

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

제한

예제 입력 1

3 3 3 3

예제 출력 1

18

An optimal arrangement using a 6ドル$-by-3ドル$ wall is shown below.

예제 입력 2

2 2 4 4

예제 출력 2

20

An optimal arrangement using a 6ドル$-by-4ドル$ wall is shown below.

예제 입력 3

1 2 3 1

예제 출력 3

12

An optimal arrangement using a 3ドル$-by-3ドル$ wall is shown below.

노트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2025 > CCC 2025 Senior Division 1번

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

출처

대학교 대회

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

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