https://www.acmicpc.net/problem/27736
27736번: 찬반투표
투표가 통과되었으면 APPROVED, 통과되지 않았으면 REJECTED, 무효 처리되었으면 INVALID를 출력한다.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
from math import ceil
def sol(nums):
if nums.count(0) >= ceil(len(nums)/2):
return 'INVALID'
elif sum(nums) <= 0:
return 'REJECTED'
else:
return 'APPROVED'
if __name__ == '__main__':
n = int(input())
nums = list(map(int, input().split()))
print(sol(nums))
|
cs |
재학생 절반 이라는 기준이 애매했는데요
재학생이 짝수일땐 상관없지만
홀수 ex) 재학생 5명 - > 재학생절반 2.5명인데 3명으로 간주해야할 듯 싶어요
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3046. Split the Array (0) | 2024.04.22 |
---|---|
leetcode 3110. Score of a String (0) | 2024.04.22 |
leetcode 3120. Count the Number of Special Characters I (0) | 2024.04.21 |
백준 31668 특별한 가지 (0) | 2024.04.19 |
백준 31428 엘리스 트랙 매칭 (0) | 2024.04.19 |
댓글