Skip to content

Commit

Permalink
Merge pull request #38 from AlgoLeadMe/10-SeongHoonC
Browse files Browse the repository at this point in the history
10-SeongHoonC
  • Loading branch information
SeongHoonC authored Feb 25, 2024
2 parents 6814e07 + b182aad commit 7a1a748
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions SeongHoonC/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@
| 7μ°¨μ‹œ | 2024.02.08 | DP | <a href="https://www.acmicpc.net/problem/1932"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/23 |
| 8μ°¨μ‹œ | 2024.02.14 | μ •λ ¬ | <a href="https://www.acmicpc.net/problem/18870"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/26 |
| 9μ°¨μ‹œ | 2024.02.21 | bfs | <a href="https://www.acmicpc.net/problem/21736"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/35 |
| 9μ°¨μ‹œ | 2024.02.23 | 그리디 | <a href="https://www.acmicpc.net/problem/1931"></a> | https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/38 |
---
35 changes: 35 additions & 0 deletions SeongHoonC/greedy/νšŒμ˜μ‹€ λ°°μ •.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
val br = BufferedReader(InputStreamReader(System.`in`))
val n = br.readLine().toInt()
var meets = mutableListOf<Pair<Int, Int>>()

for (i in 0 until n) {
val (x, y) = br.readLine().split(" ").map { it.toInt() }
meets.add(x to y)
}
meets.sortWith(compareBy({ it.second }, { it.first }))

var min = -1
var count = 0
for (i in meets.indices) {
val meet = meets[i]
// 회의 μ‹œμž‘μ΄ 이미 μ‹œμž‘ν•œ νšŒμ˜λ³΄λ‹€ μž‘μœΌλ©΄ 회의 λͺ»ν•¨
if (meet.first < min) {
continue
}
// 회의 끝이 μ΅œμ†Œκ°’λ³΄λ‹€ μž‘μœΌλ©΄ κ°±μ‹ ν•˜κ³  +1
if (meet.second > min) {
min = meet.second
count++
continue
}
// 회의 μ‹œμž‘κ³Ό 끝이 κ°™μœΌλ©΄ +1
if (meet.first == meet.second) {
count++
}
}
println(count)
}

0 comments on commit 7a1a748

Please sign in to comment.