Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- c3 초
- 1697
- c3 step graph
- c3 second
- influxdb 설치
- grafana dashboard
- gcc regex
- python popen
- c3 축 가리기
- regex_search
- semanage
- selinux port 등록
- gcc 업데이트
- CentOS7
- snmp test
- telegraf
- 정규식 컴파일
- python subprocess
- InfluxDB
- 백준
- 정규식 문자열 출력
- g++ 업데이트
- subporcess path
- c3 축 없애기
- 정규식 활용
- snmp
- centos pyhon 설치
- linux시간으로 변경
- c++ 정규식
- python os
Archives
- Today
- Total
리셋 되지 말자
[백준 2798] 블랙잭 - combinations 본문
코드
from itertools import combinations
n, m = map(int, input().split())
arr = list(map(int, input().split()))
max_num = 0
for com in combinations(arr, 3):
sum_com = sum(com)
if sum_com <= m:
max_num = max(max_num, sum(com))
print(max_num)
설명
- 조합으로 3개의 카드를 골랐을 모든 경우의 수를 구한다
- 모든 경우의 수 중, 3개의 카드의 합이 M을 넘지 않는 한에서 가장 큰 값으로 계속 갱신한다
- 최종적으로 갱신된 최대 수를 출력
'알고리즘' 카테고리의 다른 글
[백준 1436] 영화감독 숌 - 브루트포스 (0) | 2021.12.22 |
---|---|
[백준 2751] 수 정렬하기 - sys.stdin.readline (0) | 2021.12.22 |
[백준 2231] 분해합 - 브루트포스 (0) | 2021.12.22 |
[백준 1920] 수 찾기 - 해시, 이분탐색, Counter, Set (0) | 2021.12.22 |
[백준 1654] 랜선 자르기 - 이분탐색 (0) | 2021.12.22 |
Comments