思路基本没戳,why 10 points bro?

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

acommonman @ 2024-07-12 11:47:08

#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int l,a[10000],m,n=0;
int main()
{
    scanf("%d %d", &l,&m);
    memset(a, 0, sizeof(a));
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        scanf("%d %d", &u, &v);
        for (int j = u; j <= v; j++)a[j] = 1;
    }
    for (int i = 0; i <= l; i++)
        if (a[i] == 0)n++;
    printf("%d\n", n);
    return 0;
}

by _Albus_ @ 2024-07-12 11:49:23

数组开小了,多开一点


by _Albus_ @ 2024-07-12 11:52:13

@acommonman 具体内容如下


by yangyang826 @ 2024-07-12 12:11:58

统一下标


by acommonman @ 2024-07-13 13:23:19

@Albus omg蟹蟹,已过


by Jokersheng @ 2024-08-05 22:14:16

@yangyang826

捕捉好友!


|