-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestaurantCustomers.java
More file actions
31 lines (30 loc) · 1.07 KB
/
RestaurantCustomers.java
File metadata and controls
31 lines (30 loc) · 1.07 KB
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
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.StringTokenizer;
import java.util.TreeMap;
public class RestaurantCustomers {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
TreeMap<Long,Integer> map = new TreeMap<>();
for(int i=0;i<n;i++){
st = new StringTokenizer(br.readLine());
map.put(Long.parseLong(st.nextToken()),0);
map.put(Long.parseLong(st.nextToken()),1);
}
long c = 0;
long ans = Long.MIN_VALUE;
for(Long k : map.keySet()){
if(map.get(k)==0){
c++;
}else{
c--;
}
ans = Math.max(ans,c);
}
System.out.println(ans);
}
}