救救

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

你第6行数组开小了,开到10500。 还有第七行的循环范围改成0到L
by spencer @ 2023-11-14 20:36:13


@[OHMYXUAN](/user/1152380)
by spencer @ 2023-11-14 20:36:37


把数组开大一点就好了
by tooexpensivetoattend @ 2023-11-14 20:57:55


@[spencer](/user/172136) OK got it 谢谢你
by OHMYXUAN @ 2023-11-15 08:21:31


@[spencer](/user/172136) 可是还是只有30分啊
by OHMYXUAN @ 2023-11-15 08:25:57


我帮你调好了,能ac,你自己看看哪里有问题 ```cpp #include <iostream> using namespace std; int main(){ int l,m,sum=0; cin>>l>>m; int a[10500]; for(int i=0;i<=l;i++){ a[i]=1; } while(m--){ int x,y; cin>>x>>y; for(int i=x;i<=y;i++){ if(a[i]==1){ a[i]=0; } } } for(int i=0;i<=l;i++){ if(a[i]==1){ sum++; } } cout<<sum; return 0; } ```
by spencer @ 2023-11-15 13:38:34


@[OHMYXUAN](/user/1152380)
by spencer @ 2023-11-15 13:39:19


@[spencer](/user/172136) @[spencer](/user/172136) ok了 谢谢神犇
by OHMYXUAN @ 2023-11-15 18:10:13


@[OHMYXUAN](/user/1152380) 给个关注呗qaq
by spencer @ 2023-11-15 18:26:48


@[spencer](/user/172136) okey
by OHMYXUAN @ 2023-11-15 19:09:50


|