44 lines
1.2 KiB
Java
44 lines
1.2 KiB
Java
import java.util.*;
|
|
|
|
class Meeting_Hour implements Comparable<Meeting_Hour>{
|
|
public int start;
|
|
public int end;
|
|
|
|
Meeting_Hour(int start, int end){
|
|
this.start = start;
|
|
this.end = end;
|
|
}
|
|
|
|
public int compareTo(Meeting_Hour another){
|
|
if(this.end == another.end) return this.start - another.start;
|
|
return this.end - another.end;
|
|
}
|
|
}
|
|
|
|
public class _1931 {
|
|
public static void main(String[] args) {
|
|
Scanner sc = new Scanner(System.in);
|
|
ArrayList<Meeting_Hour> meetingList = new ArrayList<>();
|
|
int N = sc.nextInt();
|
|
for(int i=0; i<N; i++){
|
|
meetingList.add(new Meeting_Hour(sc.nextInt(),sc.nextInt()));
|
|
}
|
|
sc.close();
|
|
|
|
Collections.sort(meetingList);
|
|
// meetingList.sort((a,b)->{
|
|
// if(a.end == b.end) return a.start - b.start;
|
|
// return a.end - b.end;
|
|
// });
|
|
int currentEnd = meetingList.get(0).end;
|
|
int result = 1;
|
|
for(int i=1; i<N; i++){
|
|
if(currentEnd<=meetingList.get(i).start){
|
|
currentEnd = meetingList.get(i).end;
|
|
result++;
|
|
}
|
|
}
|
|
System.out.println(result);
|
|
}
|
|
}
|