[JAVA]求问大佬,为什么后面都ac了,前面第一个点RE了。

P1047 [NOIP2005 普及组] 校门外的树

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.


|