https://www.acmicpc.net/problem/10886
10886번: 0 = not cute / 1 = cute
준희는 자기가 팀에서 귀여움을 담당하고 있다고 생각한다. 하지만 연수가 볼 때 그 의견은 뭔가 좀 잘못된 것 같았다. 그렇기에 설문조사를 하여 준희가 귀여운지 아닌지 알아보기로 했다.
www.acmicpc.net
문제 풀이
- 모든 학생들의 투표 결과를 for문을 통해 list에 담는다.
- count를 사용해 0과 1의 개수를 세주고 비교하여 출력한다.
solution
import sys
t = int(sys.stdin.readline().strip())
vote_list = []
for _ in range(t):
vote_list.append(int(sys.stdin.readline().strip()))
if vote_list.count(0) > vote_list.count(1) :
print('Junhee is not cute!')
else:
print('Junhee is cute!')
다른 팀원 코드
- 각 사람들의 설문 조사를 모두 더한 다음 투표인원수의 과반이 되면 귀엽다고 출력함.
import sys
t = int(sys.stdin.readline().strip())
score = 0
for _ in range(t) :
vote = int(sys.stdin.readline().strip())
score += vote
if score > t//2:
print('Junhee is cute!')
else:
print('Junhee is not cute!')
'algorithm > 백준' 카테고리의 다른 글
[PYTHON] 2576 홀수 (0) | 2023.01.19 |
---|---|
[PYTHON] 7785 회사에 있는 사람 - 딕셔너리 value값으로 key 추출 (0) | 2023.01.19 |
[PYTHON] 10824 네 수 (0) | 2023.01.18 |
[PYTHON] 9085 더하기 sum (0) | 2023.01.18 |
[PYTHON] 3009 네 번째 점 (0) | 2023.01.18 |
댓글