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
- 오토레이아웃
- CI/CD
- 알고리즘
- 동작과정
- ai expo
- Content Compression Resistance priority
- ReactiveX
- gitlabci/cd
- 동시성프로그래밍
- mvvm
- gitlab
- OperationQueue
- 애플인텔리전스
- swift
- Union-Find
- swift알고리즘
- 자료구조
- 백준
- CICD
- rxswift
- RxSwift요약
- RxCocoa
- 클린아키텍처
- cleanarchitecture
- AI
- Content Hugging priority
- Autolayout
- LLM
- IOS
- apple intelligence
Archives
- Today
- Total
JosephCha의 개발일지
[브루트 포스]백준/2798번/블랙잭 본문
let firstLineInput = readLine()!.split(separator: " ").map{Int(String($0))!}
let secondLineInput = readLine()!.split(separator: " ").map{Int(String($0))!}
let limit: Int = firstLineInput.last!
let length: Int = secondLineInput.count
var result: Int = 0
for i in 0..<length {
for j in i+1..<length {
for k in j+1..<length {
let sum: Int = secondLineInput[i] + secondLineInput[j] + secondLineInput[k]
if sum <= limit {
result = max(result, sum)
}
}
}
}
print(result)
설명
- 세개의 for문을 통해, 모든경우의 수의 세개의 카드의 합을 구해, result에 최대값을 갱신해 준다.
- 모든 경우의 수를 탐색하기에 브루트 포스
'알고리즘 및 자료구조' 카테고리의 다른 글
[백준] 4195번 / 친구 네트워크 (Swift) (0) | 2022.08.23 |
---|---|
[스택] 백준/1874번/스택 수열 (0) | 2022.07.27 |
백준/2920번/음계 문제 (0) | 2022.07.26 |
큐 (0) | 2022.04.20 |
스택 (0) | 2022.04.20 |
Comments