haju__log
[python][백준/BOJ] 2476번 : 주사위 게임 본문
반응형
https://www.acmicpc.net/problem/2476
2476번: 주사위 게임
첫째 줄에는 참여하는 사람 수 N이 주어지고 그 다음 줄부터 N개의 줄에 사람들이 주사위를 던진 3개의 눈이 빈칸을 사이에 두고 각각 주어진다.
www.acmicpc.net
✅ 내 코드
n=int(input())
total=0
result=0
for _ in range(n):
a,b,c=map(int,input().split())
maxn=max(a,b,c)
if a==b and b==c:
same=10000+a*1000
if result < same:
result = same
elif a!=b and a!=c and b!=c :
differ=maxn*100
if result < differ:
result = differ
else:
if a==b and b!=c:
two=1000+a*100
elif a!=b and b==c :
two=1000+b*100
elif a==c and a!=b:
two=1000+a*100
if result<two:
result=two
print(result)
✅ 참고할 만한 코드! 간결
def main():
n=int(input())
result=[]
for i in range(0,n):
a,b,c=map(int,input().split())
if(a==b==c):
result.append(10000+a*1000)
elif(a==b or a==c):
result.append(1000+a*100)
elif(b==c):
result.append(1000+b*100)
else:
result.append(100*max(a,b,c))
print(max(result))
main()
반응형
'BOJ_백준' 카테고리의 다른 글
[python][백준/BOJ] 7287번 : 등록 (0) | 2023.03.09 |
---|---|
[python][백준/BOJ] 4101번 : 크냐? (0) | 2023.03.09 |
[python][백준/BOJ] 10699번 : 오늘 날짜 (0) | 2023.03.09 |
[python][백준/BOJ] 2935번 : 소음 (0) | 2023.03.09 |
[python][백준/BOJ] 10102번 : 개표 (0) | 2023.03.08 |