Beluwuga @ 2023-09-05 12:31:14
#include<bits/stdc++.h>
using namespace std;
int metro[505]={};
int tree,area,head,tail,ans;
int main()
{
cin>>tree>>area;
for(int i=0;i<area;i++)
{
cin>>head>>tail;
for(int j=head;j<tail;j++)
metro[j]=1;
}
for(int i=0;i<tree;i++)
if(metro[i]==0)
ans++;
cout<<ans-1<<endl;
return 0;
}
by dthythxth_Huge_Brain @ 2023-09-05 12:46:09
@Beluwuga 数组开到114514
by 彗星七号 @ 2023-09-05 13:13:12
@Huge_Brain 好臭的数组,但是能过
by Beluwuga @ 2023-09-05 21:45:11
@Huge_Brain 数组开到114514变成全WA了
by q1025 @ 2023-10-16 08:13:32
@Beluwuga metro数组开到10005;循环j<tail改成j<=tail,i<tree改为i<=tree;输出改成ans 就A了
by q1025 @ 2023-10-16 08:20:25
#include<bits/stdc++.h>
using namespace std;
int metro[10005]={};//
int tree,area,head,tail,ans;
int main()
{
cin>>tree>>area;
for(int i=0;i<area;i++)
{
cin>>head>>tail;
for(int j=head;j<=tail;j++)//
metro[j]=1;
}
for(int i=0;i<=tree;i++)//
if(metro[i]==0)
ans++;
cout<<ans<<endl;//
return 0;
}
贴这里啦改的不多吧
by Beluwuga @ 2023-10-20 18:22:43
@Q1025 非常感谢