就例子对怎么改啊

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

wlt123456 @ 2023-10-25 12:57:43

#include<stdio.h>
int main() {
    int a[1000] = { 0 };
    int l,n;
    scanf("%d %d", &l,&n);
    int j, k,cnt=0;
    for (int x = 1; x <= n; x++) {
        scanf("%d %d", &j, &k);
        for (int p = j; p<= k; p++) {
            a[p] = -1;

        }

    }
    for (int i = 0; i <= l; i++) {
        if (a[i] != -1) cnt++;
    }
    printf("%d", cnt);
    return 0;
}

by heyx0201 @ 2023-10-25 13:04:40

@wlt123456

题目:l \le 10^4

你写的:

int a[1000] = { 0 };

|