Aniko @ 2023-11-09 11:26:19
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner cin = new Scanner(System.in);
int l = cin.nextInt(), m = cin.nextInt(), n = 0;
int u, v;
boolean road[] = new boolean[l];
while (n < m) {
u = cin.nextInt() - 1;
v = cin.nextInt() - 1;
while (u <= v) {
road[u] = true;
u++;
}
n++;
}
n = 0;
int amount = l + 1;
while (n < l) {
if (road[n] == true) {
amount--;
}
n++;
}
System.out.println(amount);
}
}
第一个点显示
Runtime Error.
Program exited with code 1.