import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
Resident[] residents = new Resident[n];
for(int i = 0; i < n; i++){
StringTokenizer st = new StringTokenizer(br.readLine());
residents[i] = new Resident(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken()));
}
Arrays.sort(residents);
List<Resident> given_a_book = new ArrayList<>();
for(int i = n-1; i >= 0; i--){
boolean under_influence = false;
for(Resident r : given_a_book){
if ((Math.abs(r.position-residents[i].position)<=r.influence-residents[i].influence)){
under_influence = true;
break;
}
}
if(!under_influence){
given_a_book.add(residents[i]);
}
}
System.out.println(given_a_book.size());
}
static class Resident implements Comparable<Resident>{
int position;
int influence;
public Resident(int position, int influence){
this.position = position;
this.influence = influence;
}
public int compareTo (Resident r){
return this.influence - r.influence;
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |