题解
2023-08-25 09:38:21
发布于:广东
5阅读
0回复
0点赞
#include <iostream>
using namespace std;
const int N = 100010;
const int mod = 1e4+7;
int n,m;
int idx[N],color[N];
int cnt[N][2];
int sum[N][2];
int main()
{
cin>>n>>m;
for(int i = 1;i <= n;i++)
{
cin>>idx[i];
idx[i] = idx[i]%mod;
}
for(int i = 1;i <= n;i++)
{
int c;
cin>>c;
color[i] = c;
cnt[c][i%2]++;
sum[c][i%2] = (sum[c][i%2]+idx[i])%mod;
}
long long ans = 0;
for(int i = 1;i <= n;i++)
{
int c = color[i];
ans += i*((sum[c][i%2]+((cnt[c][i%2]-2)*idx[i]%mod+mod))%mod)%mod;
ans %= mod;
}
cout<<ans;
return 0;
}
这里空空如也
有帮助,赞一个