C++全是RE!

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

songchunxi @ 2023-06-28 13:44:39


#include <bits/stdc++.h>
using namespace std;
int l,m,i,j,a,b,ans=0;
int q[105];
int main(){
    cin>>l>>m;
    for(i=0;i<=l;i++){
        q[i]=1;
    }
    for(i=0;i<m;i++){
        cin>>a>>b;
        for(j=a;j<=b;j++){
            q[j]=0;
        }
    }
    for(i=0;i<=l;i++){
        if(q[i]==1) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

by FengYuXinMing @ 2023-06-28 13:45:42

数组开小了


by FengYuXinMing @ 2023-06-28 13:47:13

开十的四次方 1e4+5或者10005(建议多开5个)


by songchunxi @ 2023-06-28 13:50:23


|