[Algorithm] 백준 23854번

Captainjack·2022년 2월 23일
0

Algorithm

목록 보기
10/10

The famous programming contest organizer decided to hold competition for champions "The Battle of Giants". There are two teams competing in the battle. Several matches are organized for the competition.

Each match can end with a win for one of the teams, or with a draw. When a team wins the match it scores 3 points, in this case the opposite team doesn't score any point. In the case of a draw, teams score 1 point each. After all the matches end, the final score aa:bb is calculated: aa and bb --- the number of points scored by the first and second team, respectively.

For example, if the first match is won by the first team, the second match ended with a draw, and the third match is also won by the first team, the final score is 7:1.

You are given the final score. Find out whether the given score is possible, and what is the minimum number of matches could be. Print the number of matches won by the first team, the number of matches ended with a draw, and the number of matches won by the second team.


a팀 점수, b팀 점수를 입력 받고

해당 점수가 계산이 되어지면 (계산 방법은 바로 하단)

출력으로 a팀 점수, 드로우, b팀 점수 출력

불가능하면 -1 출력


계산 방법

어느 한쪽이 이기면 +3 점, 비기면 모든 팀 +1점


Ex)
1. 입력(7:1) 일경우 a팀이 2번이기고 (a팀 6점)
2. draw 한번이면 (a팀 1점, b팀 1점)
3. 입력 값이 7 1이 완성.
4. 출력은 2 1 0

Ex)
1. 입력(2:1)이면
2. 드로우를 한번 한다고해도 (a팀 1점, b팀 1점)
3. a팀 1점을 혼자만 깎을 방법이 없기 떄문에 불가능 판단 -1 출력


매우 간단한 문제..

지만


도움이 될 만한 테스트 케이스
1. 정답(15%) 오류 : 0, 0 입력을 받으면 -1이아니라 0 0 0 이 나오게 출력해야 함
2. 정답(87%) 오류 : 3, 3 입력 받으면 0 3 0이 아니라 1 0 1이 나오게 출력해야 함

profile
til' CTF WIN

0개의 댓글