o_CIHL @ 2024-02-07 00:49:25
#include<stdio.h>
int main(){
int l,m;
scanf("%d%d",&l,&m);
int a,b;
int s[l++];
int i,j,k;
for(i=0;i<l;i++){
s[i]=0;
}
for(i=0;i<m;i++){
scanf("%d%d",&a,&b);
for(j=a;j<=b;j++){
s[j]=1;
}
} k=l;
for(i=0;i<k;i++){
l-=s[i];
}
printf ("%d",l);
return 0;
}
int main(){ int l,m; scanf("%d%d",&l,&m); int a,b; int s[l++]; int i,j,k; for(i=0;i<l;i++){ s[i]=0; } for(i=0;i<m;i++){ scanf("%d%d",&a,&b); for(j=a;j<=b;j++){ s[j]=1; } } k=l; for(i=0;i<k;i++){ l-=s[i]; } printf ("%d",l); return 0; }
by 杜都督 @ 2024-02-07 01:10:04
int s[++l];
by o_CIHL @ 2024-02-07 01:22:59
@杜都督 明白了,,感谢大佬