Codeforces Round #560 (Div. 3) E - Two Arrays and Sum of Functions (结论题)

⏰ ⏰ ⏰

重点在排序不等式,然而我不知道!QAQ

在这里插入图片描述

#define mod 998244353
#define int ll
signed main()
{
    int  n;cin>>n;
    vector<int> a(n),b(n);cin>>a>>b;
    rep(i,n) a[i] *= (i+1)*(n-i);
    sort(all(a)),sort(all(b),[](int x,int y){return x>y;});
    ll ans=0;
    rep(i,n) 
    {
        a[i]%= mod;
        b[i]%= mod;
        ans=(ans+a[i]*b[i] ) %mod;
    }
    cout<<ans<<endl;
	return 0;
}
发布了82 篇原创文章 · 获赞 1 · 访问量 1416

猜你喜欢

转载自blog.csdn.net/weixin_44116061/article/details/104113235