洛谷P1047报错,但例子可以正常得出结果

img

img

洛谷上的P1047,我在自己的编译器上运行可以,也找了同学帮忙看,都觉得没问题,但是在洛谷的编译器上一直报错。下面是我的代码。


#include
using namespace std;
int main()
{
    int length, number,count=0;//count剩多少树
    cin >> length >> number; //length路的长度,number几个范围
    int a[1000] = { 0 };//建筑的坐标
    int b[1000] = { 0 };//树的坐标
    for (int i = 0; i < 2 * number; i++)
    {
        cin >> a[i];//输入三个建筑的坐标范围(有六个点)
    }
    for (int i = 0; i < 2 * number; i+=2)
    {
        for (int j = a[i]; j<=(a[i+1]); j++)
        {
            b[j] = 1;//将在建筑范围内的数字变为1
        }
    }
    for (int i = 0; i <= length; i++)
    {
        if (b[i] == 0)
            count++;
    }
    cout << count << endl;
    system("pause");
    return 0;
}

system("pause");
这是windows平台特有的,oj一般不能这么写