We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5e814f4 commit 42d6972Copy full SHA for 42d6972
src/3week/jaewon/회의실 배정.kt
@@ -0,0 +1,33 @@
1
+
2
+class jaewon회의실배정 {
3
4
+ data class TimeTable(val start : Int, val end : Int)
5
6
+ fun solution(){
7
+ val n = readln().toInt()
8
+ val timeTable = mutableListOf<TimeTable>()
9
+ var endTime = 0
10
+ var count = 0
11
12
+ repeat(n){
13
+ val (start,end) = readln().split(" ").map { it.toInt() }
14
+ timeTable.add(TimeTable(start, end))
15
+ }
16
17
+ timeTable
18
+ .sortedWith( compareBy<TimeTable> { it.end }.thenBy { -(it.end - it.start) })
19
+ .forEach {
20
+ if (it.start >= endTime){
21
+ count++
22
+ endTime = it.end
23
24
25
26
+ println(count)
27
28
+}
29
30
+fun main(){
31
+ jaewon회의실배정().solution()
32
33
0 commit comments