-
[백준] 2798 python - 블랙잭(브론즈 2)알고리즘 문제/풀어본 것 2022. 10. 22. 16:58
https://www.acmicpc.net/problem/2798
1트
sum(iterable 객체)
iterable 객체의 합을 return한다.
https://docs.python.org/ko/3/library/functions.html?highlight=built%20function#summax(iterable 객체)
max(arg1, arg2)
인자 값 중 최댓값을 리턴한다.
https://docs.python.org/ko/3/library/functions.html?highlight=built%20function#max내 풀이
import sys from itertools import combinations n, m = map(int, sys.stdin.readline().rstrip().split()) cards = list(map(int, sys.stdin.readline().rstrip().split())) result = 0 for candidate in combinations(cards, 3): candidate_sum = sum(candidate) if candidate_sum <= m: result = max(result, candidate_sum) print(result)
'알고리즘 문제 > 풀어본 것' 카테고리의 다른 글
[백준] 10828 - 스택(실버 4) (0) 2022.10.24 [백준] 1003 python - 피보나치 함수(실버 3) (0) 2022.10.22 [백준] 2751 python- 수 정렬하기 2(실버 5) (0) 2022.10.22 [백준] 11050 python- 이항 계수 1(브론즈 1) (0) 2022.10.22 [백준] 10828, 10845, 10866 python - 스택, 큐, 덱(실버 4) (0) 2022.10.22