본문으로 바로가기

[백준/Python(파이썬)] 2309 일곱 난쟁이

category PS/백준 2021. 2. 14. 17:11

2021-02-01

문제 : https://www.acmicpc.net/problem/2309

 

2309번: 일곱 난쟁이

아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다.

www.acmicpc.net

스페셜 저지 붙어있는 문제는 처음 풀어본다

브루트 포스는! 일단 무식하게 풀기! 문제가 시키는 대로 구현하기!

 

[소스코드]

s = [-1]*9
for i in range(9):
    s[i] = int(input())
s = sorted(s)
for i in range(8):
    for j in range(i+1, 9):
        if sum(s) - (s[i]+s[j]) == 100:
            s1 = s[i]
            s2 = s[j]

s.remove(s1)
s.remove(s2)
for i in s:
    print(i)

https://github.com/jisun1125/algorithm-problem-solving/blob/main/baekjoon/no_2309.py

 

jisun1125/algorithm-problem-solving

Algorithms. Contribute to jisun1125/algorithm-problem-solving development by creating an account on GitHub.

github.com