백준: 16727번 ICPC (Python3)
ICPC 성공다국어
2 초 | 512 MB | 1086 | 709 | 670 | 65.239% |
문제
The Iranian ChamPions Cup (ICPC), the most prestigious football league in Iran, is reaching its end, and people are eagerly waiting for the finals, which happened to be between the two most popular Iranian teams, Persepolis and Esteghlal.
The ICPC finals consist of two matches, with each team competing as the home team in one match. The winning team is determined by aggregate score, the sum of the scores of the two matches. For example, if the scores of the two matches are Persepolis 6–0 Esteghlal in the first match, and Esteghlal 3–1 Persepolis in the second match, then the aggregate score will be Persepolis 7–3 Esteghlal, meaning that Persepolis is the winner. If aggregates are equal, the away goals rule is used to determine the winner, in which case the winner is the team that scored the most goals in the match it played away from home. If the result is still equal, a penalty shootout is required.
Hana, an avid football fan, is trying to figure out various scenarios in which her favorite team wins the finals. To this end, she aims to write a program that gets as input the number of goals in the two matches, and decides which team is the winner if it can be derived from the aggregate scores and the away goals rule, otherwise declares that the match goes to penalty kicks. You are going to help Hana write such a program.
입력
The first line of the input contains two space-separated integers p1 and s1, where p1 and s1 are the number of goals scored by Persepolis and Esteghlal, respectively, in the first match in which Persepolis is the home team. The second line contains two space-separated integers s2 and p2, where s2 and p2 are the number of goals scored by Esteghlal and Persepolis, respectively, in the second match in which Esteghlal is the home team. All input integers are between 0 and 20, inclusively.
출력
In the output, print the name of the winning team, either Persepolis or Esteghlal, if the winner can be determined by the aggregate scores and the away goals rule. Otherwise, print Penalty.
예제 입력 1
3 0
2 1
예제 출력 1
Persepolis
예제 입력 2
3 1
2 0
예제 출력 2
Esteghlal
예제 입력 3
2 0
2 0
예제 출력 3
Penalty
답안
1
2
3
4
5
6
7
8
9
10
11
12
|
p1, s1 = map(int, input().split()) #p's home
s2, p2 = map(int, input().split()) #s's home
if (p1+p2) == (s1+s2):
if s1 == p2:
print("Penalty")
elif (s1>p2):
print("Esteghlal")
else:
print("Persepolis")
else:
print("Esteghlal" if (s1+s2)>(p1+p2) else "Persepolis")
|
cs |
'공부 > 코딩테스트' 카테고리의 다른 글
백준: 16600번 Contemporary Art (Python3) (0) | 2022.08.11 |
---|---|
백준: 16693번 Pizza Deal (Python3) (0) | 2022.08.10 |
백준: 14489번 치킨 두 마리 (Python3) (0) | 2022.08.10 |
백준: 17356번 욱 제 (Python3) (0) | 2022.08.10 |
백준: 17362번 수학은 체육과목 입니다 2 (Python3) (0) | 2022.08.10 |
댓글