import java.util.Scanner;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int l = sc.nextInt();
int m = sc.nextInt();
int[] flags = new int[l + 1];
//对移走的树进行标记
for (int i = 0; i < m; i ++) {
int x = sc.nextInt();
int y = sc.nextInt();
for (int j = x; j <= y; j ++) {
flags[j] = 1;
}
}
//等于0即没被标记过,也就是说还没被移走
int cnt = 0;
for (int i = 0; i <= l; i ++) {
if (flags[i] == 0)
cnt ++;
}
System.out.println(cnt);
}
}
KY25 剩下的树
最新推荐文章于 2024-10-30 18:07:32 发布