有没有人能告诉我为什么RE

给定两个有序的AB数组,将他们合并成增序数组,并将两两元素之间的差累加起来并对10000000007取模输出。
1<=n<=1e7
1<=ai<=1e10

#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
// const int MAX_N=1e5+10;
// const int MX=100;
// const ll BASE=131;
const ll MOD=10000000007;
// const int mxN=84;
// const int mxK=14;
// const int MAXSIZE=300;
map<ll,ll> mp;
ll a[10000010],len=0;
ll n,m,ans=0;
int main(){
    freopen("test5.in","r",stdin);
    freopen("test5.out","w",stdout);
    cin>>n>>m;
    for(ll i=0,j;i<n;i++){
        scanf("%lld",&j);
        mp[j]++;
    }
    for(ll i=0,j;i<m;i++){
        scanf("%lld",&j);
        mp[j]++;
    }
    for(const auto &i:mp){a[len++]=i.first;}
    for(ll i=0;i<len-1;i++){
        ans+=(a[i+1]-a[i]);
        ans%=MOD;
    }
    printf("%lld",ans);
    fclose(stdin);
    fclose(stdout);
    return 0;
}

给题面!

呃呃,unsigend long long不是%u么

@向耕立 @向耕立

我是是

没用

给题面

给了

我要截图!!

有可能是你的数组下标是unsigned long long类型,所以错了

你开long long试试

2025-04-17 19-59-11屏幕截图

ohohoh,原来是你a[ ]开大了!!!开不到1e7,你开数组不行,你直接mp用上就行了

这里的a[ ]改成mp

int last=0;
for(const auto &i:mp){
	ans+=(i.first-last);
    ans%=MOD;
    last=i.first;
}

蟹蟹