10分求助!!!

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

Asakimi @ 2022-12-14 13:40:47

#include<bits/stdc++.h>
using namespace std;
int a1[10000];
int a2[10000];
int s[10000];
int l,m,ans;
int move(int a,int b);
int main() {
    cin>>l>>m;
    for(int y=1; y<=m; y++) {
        cin>>a1[y]>>a2[y];
    }
    for(int u=1; u<=m; u++) {
        move(a1[u],a2[u]);
    }
    for(int k=0; k<=l; k++) {
        if(s[k]==0) ans++;
    }
    cout<<ans;
    return 0;
}
int move(int a,int b) {
    for(int p=a; p<=b; p++) {
        s[p]=1;
    }
}

by Night_sea_64 @ 2022-12-14 13:46:13

@Asakimi 数组开大点


by Asakimi @ 2022-12-14 13:48:39

@Netherite_sword_666 666,离谱,感谢!!!


by Asakimi @ 2022-12-14 13:49:10

过了XD


|