백준: 21631번 Checkers (Python3)
Checkers 성공다국어
1 초 | 512 MB | 766 | 484 | 452 | 62.259% |
문제
Dima is bored of playing checkers with himself. Since there is nothing but checker pieces to play with, he came up with the following game.
Each piece he has is either white or black. Dima builds a tower by stacking his pieces on top of each other in some order. A black stripe is a sequence of adjacent black pieces, with either a white piece, or the end of the tower at the bottom and top of it. In other words, two adjacent black pieces always belong to the same black stripe. The goal of the game is to get the maximum number of black stripes in the tower.
The game has just started. Dima has a white and b black pieces. What is the maximum number of black stripes he can get in his tower?
입력
The only line of input contains two integers a and b --- the number of white and black pieces, respectively (0≤a,b≤1018 ).
출력
Output a single integer --- the maximum possible number of black stripes.
예제 입력 1
1 2
예제 출력 1
2
예제 입력 2
5 2
예제 출력 2
2
예제 입력 3
0 3
예제 출력 3
1
답안
1
2
3
|
white,black = map(int, input().split())
print(black if white>=black else white+1)
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 21598번 SciComLove (Python3) (0) | 2022.08.09 |
---|---|
백준: 21612번 Boiling Water (Python3) (0) | 2022.08.09 |
백준: 21633번 Bank Transfer (Python3) (0) | 2022.08.09 |
백준: 21638번 SMS from MCHS (Python3) (0) | 2022.08.09 |
백준: 21665번 Миша и негатив (Python3) (2) | 2022.08.09 |
댓글