일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- kotlin
- java
- LEVEL2
- 그래프
- OS
- back-end
- 백준
- 코틀린
- 프로그래머스
- 네트워크
- 자바
- 자료구조
- algorithm
- BFS
- TDD
- 알고리즘
- baekjoon
- 백트래킹
- 모던자바
- 스프링
- programmers
- Java8
- Brute-force
- DFS
- 운영체제
- 프로젝트
- Spring
- lambda
- backtracking
- DP
- Today
- Total
목록백트래킹 (6)
요깨비's LAB
import java.util.* var C:Int = 0 fun main() { val scr = Scanner(System.`in`) C = scr.nextInt() val results = StringBuffer() for(i in 0 until C) { val N = scr.nextInt() val scores = mutableListOf() var total = 0 for(j in 0 until N) { val score = scr.nextInt() total += score scores.add(score) } val avg = total/N var count = 0 for(j in 0 until N) { if(scores[j] > avg) count++ } val result = String...
import java.util.* var energyBalls = mutableListOf() var N: Int = 0 var max = Int.MIN_VALUE fun main() { val scr = Scanner(System.`in`) N = scr.nextInt() for (i in 0 until N) { val element = scr.nextInt() energyBalls.add(element) } doAlgorithm(0, 0, N) println(max) } fun doAlgorithm(count: Int, value: Int, size: Int) { if (energyBalls.size == 2) { max = if (max < value) value else max return } f..
import java.util.* var N = 0 var max = Int.MIN_VALUE var min = Int.MAX_VALUE val elements = mutableListOf() val operators = mutableListOf() fun main() { val scr = Scanner(System.`in`) N = scr.nextInt() for (i in 0 until N) { val element = scr.nextInt() elements.add(element) } for (i in 0 until 4) { val operator = scr.nextInt() operators.add(operator) } doAlgorithm(1, elements[0]) println(max) pr..
import java.util.* var k = 0 var inEqualitySigns: Array? = null var visited: Array? = null var results = mutableListOf() fun main() { val scr = Scanner(System.`in`) k = scr.nextInt() visited = Array(10) { false } inEqualitySigns = Array(k) { "" } for (i in 0 until k) { val element = scr.next() inEqualitySigns!![i] = element } doAlgorithm(0, "", -1) results.sort() println(results[results.size-1])..
import java.util.* var isComplete = false class ZeroArea( var row: Int, var col: Int, var visited: Array = Array(9) { false } ) val map = Array(9) { Array(9) { 0 } } fun main() { val scr = Scanner(System.`in`) val zeroAreas = mutableListOf() for (i in 0 until 9) { for (j in 0 until 9) { map[i][j] = scr.nextInt() if (map[i][j] == 0) { zeroAreas.add(ZeroArea(i, j)) } } } for (zeroArea in zeroAreas..
import java.util.* var N: Int = 0 var M: Int = 0 val sb = StringBuffer() fun main() { val scr = Scanner(System.`in`) N = scr.nextInt() M = scr.nextInt() for(i in 1..N) { val str = StringBuffer() dfs(i, str.append(i).append(" "), 1) } print(sb.toString()) } fun dfs(n:Int, str: StringBuffer,count: Int) { if(count == M) { sb.append(str.toString() + "\n") return } val n = n+1 for(i in n..N) { var s ..