/**
创建一个长度为L的数组lArr, 循环判断 如果lArr[i]在地铁范围内, 则做标记. 最后统计没
有被标记的数量
L: 马路长度
N: 地铁数量
arr: 每段地铁的起始和终点
样例输入:
500 3
150 300
100 200
470 471
样例输出:
298
/
public class railway {
public static int c(){
Scanner sc=new Scanner(System.in);
int L= sc.nextInt();
int N=sc.nextInt();
int result = 0;
// 标记数组lArr
boolean[] larr=new boolean[L+1];
int [][]arr=new int[2][2];
for (int i=0;i<=arr.length;i++){
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
arr[i]=new int[]{a,b,c};
}
// sc.nextLine();//用来跳过行列后的回车符
// 对每段地铁进行判断
for (int i=0;i<N;i++){
// 第i段地铁 起始点为[i][0] 终点为[i][1]
for (int j=arr[i][0];j<=arr[i][1];j++){
// 标记
larr[j]=true;
}
}
// 统计没有被标记的数量
while (L!=-1){
if (!larr[L--]) result++;
}
return result;
}
public static void main(String[] args) {
System.out.println(c());
}
}