루미 알고리즘

#1552브론즈Green Card

PO 2022 학교 예선코딩출제 Fredrik Hernqvist영어 원문이 문제가 어렵다면 — 배우는 순서 보기

영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)

Problem

To climb, two people are required: one to climb and one to stay on the ground and hold the rope (belay) in case the climber falls. To belay, one must have a green card. However, one does not need a green card to climb.

Climbing a wall, including tying the rope to the harness and everything around it, takes exactly 10 minutes. There are many climbing walls available, so any number of people can climb simultaneously (but they must be belayed by different people).

A group of friends consists of N people with green cards and M people without green cards. How many minutes will it take at a minimum before everyone has had a chance to climb once?

Input

The first line contains an integer N (2 ≤ N ≤ 400,000,000), the number of people with a green card.

The second line contains an integer M (0 ≤ M ≤ 400,000,000), the number of people without a green card.

Output

Print: the minimum number of minutes required before all N + M people have had a chance to climb.

Scoring

Your solution will be tested on a set of test groups, each worth a number of points. Each test group contains a set of test cases. To get the points for a test group you need to solve all test cases in the test group.

GroupPointsConstraints
120M = 0
220N = 2
340M, N ≤ 100
420No additional constraints.

Explanation of Examples

In the first example, there are two people, both with green cards. One person belays while the other climbs, and then they can switch roles. In total, it takes 20 minutes for both people to have climbed.

In the second example, there are four people, two of whom have green cards. The two people with green cards can both climb during the first 20 minutes (as in the first example). Then, the two people without green cards can climb simultaneously. Thus, it takes a total of 30 minutes for everyone to have climbed.

In the third example, there are six people, three of whom have green cards. One way to achieve climbing in 30 minutes is to have always two people climbing at the same time, one with a green card and one without.

예제

예제 1

입력
2
0
출력
20

예제 2

입력
2
2
출력
30

예제 3

입력
3
3
출력
30

출처 표기

출처: Programmeringsolympiaden 2022년 학교 예선 · 원문 페이지 · 이용 조건 CC BY-SA · LaTeX 원문을 화면용 글로 옮겼습니다(수식·표의 모양이 다를 수 있습니다). 내용은 고치지 않았습니다.

크리에이티브 커먼즈 저작자표시-동일조건변경허락.

문제 출처: 한국정보올림피아드(KOI) (CC BY-NC-SA 4.0) · International Olympiad in Informatics (IOI) (CC BY) · Centre for Education in Mathematics and Computing (CEMC), University of Waterloo (CC BY-NC 4.0) · Programmeringsolympiaden (CC BY-SA) · CSES Problem Set (Antti Laaksonen) (CC BY-NC-SA 4.0). 루미 알고리즘은 위 단체들과 관계없는 별도의 서비스이며, 자료는 원문 그대로 싣습니다. 문제마다 출처와 이용 조건을 따로 표기합니다.