import java.util.*;
class Pair<T, U> {
private T key;
private U value;
public Pair(T key, U value)
{
this.key = key;
this.value = value;
}
public T getKey() { return key; }
public U getValue() { return value; }
}
class GFG {
public static boolean checkJobs(int[] startin,
int[] endin, int n)
{
List<Pair<Integer, Integer> > a = new ArrayList<>();
for (int i = 0; i < n; i++)
a.add(new Pair<Integer, Integer>(startin[i],
endin[i]));
Collections.sort(
a, new Comparator<Pair<Integer, Integer> >() {
public int compare(Pair<Integer, Integer> a,
Pair<Integer, Integer> b)
{
return a.getKey().compareTo(b.getKey());
}
});
long tv1 = a.get(0).getValue(),
tv2 = a.get(1).getValue();
for (int i = 2; i < n; i++) {
if (a.get(i).getKey() >= tv1) {
tv1 = tv2;
tv2 = a.get(i).getValue();
}
else if (a.get(i).getKey() >= tv2)
tv2 = a.get(i).getValue();
else
return false;
}
return true;
}
public static void main(String[] args)
{
int[] startin
= { 1, 2, 4 };
int[] endin = { 2, 3, 5 };
int n = startin.length;
System.out.println(checkJobs(startin, endin, n));
}
}