본문 바로가기

전체 글145

[백준] 알파벳 (1987)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/1987 문제 참고 : https://hyeooona825.tistory.com/65 import java.io.BufferedReader import java.io.InputStreamReader var R: Int = 0 var C: Int = 0 var check: BooleanArray = BooleanArray(26) var map: Array = arrayOf() var visited: Array = arrayOf() val dx: IntArray = intArrayOf(1, -1, 0, 0) val dy: IntArray = intArrayOf(0, 0, 1, -1) fun main() = with(BufferedRead.. 2020. 4. 7.
[백준] N-Queen (9663)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/9663 문제 참고 : https://javannspring.tistory.com/179 import java.util.* import kotlin.math.abs var n: Int = 0 var answer: Int = 0 var col: IntArray = intArrayOf() fun main() { val sc: Scanner = Scanner(System.`in`) n = sc.nextInt() col = IntArray(n) for (i in 0 until n) { col[0] = i nQueen(i, 0) } println(answer) } fun nQueen(x: Int, y: Int) { for (i in 0 unt.. 2020. 3. 18.
[백준] 로또 (6603)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/6603 문제 참고 : https://zoonvivor.tistory.com/108 import java.util.* var n = 0 var arr: IntArray = intArrayOf() var visited: BooleanArray = booleanArrayOf() fun main() { val sc: Scanner = Scanner(System.`in`) while (true) { n = sc.nextInt() if (n == 0) break arr = IntArray(n) visited = BooleanArray(n) for (i in 0 until n) { arr[i] = sc.nextInt() } dfs(0, 0) p.. 2020. 2. 26.
[백준] 퇴사 (14501)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/14501 문제 참고 : https://aig2029.tistory.com/75 import java.util.* fun main() { val sc: Scanner = Scanner(System.`in`) val n: Int = sc.nextInt() var t: IntArray = IntArray(n+1) var p: IntArray = IntArray(n+1) var dp: IntArray = IntArray(n+1) for (i in 1 until n+1) { t[i] = sc.nextInt() p[i] = sc.nextInt() } var max: Int = 0 for (i in 1 until n+1) { dp[i] = Ma.. 2020. 2. 26.
[백준] 회의실배정 (1931)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/1931 문제 참고 : https://ju-nam2.tistory.com/44 import java.util.* class Meeting : Comparable { var start: Int = 0 var end: Int = 0 constructor(start: Int, end: Int) { this.start = start this.end = end } override fun compareTo(other: Meeting): Int { if (this.end == other.end) { return Integer.compare(this.start, other.end) } else { return Integer.compare(this... 2020. 2. 20.
[백준] 동전 0 (11047)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/11047 import java.util.* fun main() { val sc: Scanner = Scanner(System.`in`) val N: Int = sc.nextInt() val AIM: Int = sc.nextInt() var coinList: IntArray = IntArray(N) for (i in 0 until N) { coinList[i] = sc.nextInt() } coinList.sortDescending() var cnt: Int = 0 var sum: Int = 0 for (i in 0 until N) { while (true) { if (coinList[i] < AIM) { if (coinList[i].. 2020. 2. 20.
[백준] ATM (11399)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/11399 import java.util.* fun main() { val sc: Scanner = Scanner(System.`in`) val N: Int = sc.nextInt() var time: IntArray = IntArray(N) for (i in 0 until N) { time[i] = sc.nextInt() } Arrays.sort(time) var t: Int = 0 var sum: Int = 0 for (i in 0 until N) { t += time[i] sum += t } println(sum) } 2020. 2. 20.
[백준] 상범 빌딩 (6593)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/6593 문제 참고(두번째) : https://suriisurii.tistory.com/7 실패(메모리 초과) import java.io.BufferedReader import java.io.InputStreamReader import java.util.* var L: Int = 0 var R: Int = 0 var C: Int = 0 var map: Array = arrayOf() var distance: Array = arrayOf() fun main() = with(BufferedReader(InputStreamReader(System.`in`))) { var lrc = readLine().split(" ") L = lrc[0].. 2020. 2. 20.
[백준] 녹색 옷 입은 애가 젤다지? (4485)(Kotlin) 원본 문제 : https://www.acmicpc.net/problem/4485 import java.io.BufferedReader import java.io.InputStreamReader import java.util.* var n: Int = 0 var map: Array = arrayOf() var distance: Array = arrayOf() var cnt: Int = 1 val dRow: IntArray = intArrayOf(-1,1,0,0) val dCol: IntArray = intArrayOf(0,0,-1,1) fun main() = with(BufferedReader(InputStreamReader(System.`in`))) { n = readLine().toInt() while.. 2020. 2. 19.