80分C语言,第二和第三个通不过,求助!!

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

Z2912834546 @ 2022-08-13 18:56:56


#include<stdio.h>
int main() {
    int l, m, u, v, sum = 0, i, x[10000] = {0}, max = 0, j;
    scanf("%d %d", &l, &m);
    for (i = 0; i < m; i++) {
        scanf("%d %d", &u, &v);
        for (j = u; j <= v; j++)
            x[j] = 1;
    }
    for (i = 0; i <= l; i++)
        if (x[i] == 1)
            sum++;
    printf("%d", l+1-sum);
    return 0;

}

by lizixuan1018 @ 2022-08-18 11:08:23

加上

using namespace std;

在第二排;

max = 0

是多余的


|