题解
2023-03-11 22:08:45
发布于:上海
115阅读
0回复
0点赞
/Lucky_Glass/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int read() //读入优化走起
{
int x=0;char ch=getchar();
while(ch<'0' || ch>'9') ch=getchar();
while('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
return x;
}
const int Mod=10007;
int num[100005],color[100005],ans[100005][2],len[100005][2];
int main()
{
int n=read(),m=read();
for(int i=1;i<=n;i++)
num[i]=read();
for(int i=1;i<=n;i++)
{
int Color=color[i]=read();
ans[Color][i%2]+=num[i];
len[Color][i%2];
ans[Color][i%2]%=Mod;
len[Color][i%2]%=Mod;
}
long long Ans=0;
for(int i=1;i<=n;i)
Ans+=(ans[color[i]][i%2]+(len[color[i]][i%2]-2)num[i]%Mod)%Modi,Ans%=Mod;
printf("%lld\n",Ans);
return 0;
}
这里空空如也
有帮助,赞一个