Two Arrays and Sum of Functions
https://codeforces.com/contest/1165/problem/E
题意:重新排序b数组,使得答案最小
题解:排序+贪心
a数组不变
定义
对于排序固定的,中,在ANS中的出现次数与有关,其次数为
其中可以视作定值
定义
所以答案即重新排列Di和Bi的,其中D和B的排序顺序相反
/*
*@Author: STZG
*@Language: C++
*/
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<string>
#include<vector>
#include<bitset>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
//#define DEBUG
#define RI register int
#define endl "\n"
using namespace std;
typedef long long ll;
//typedef __int128 lll;
const int N=200000+10;
const int M=100000+10;
const int MOD=998244353;
const double PI = acos(-1.0);
const double EXP = 1E-8;
const int INF = 0x3f3f3f3f;
int t,n,m,k,p,l,r,u,v;
int ans,cnt,flag,temp,sum;
ll a[N],b[N];
char str;
struct node{};
int main()
{
#ifdef DEBUGfreopen("input.in", "r", stdin);//freopen("output.out", "w", stdout);
#endif//ios::sync_with_stdio(false);//cin.tie(0);//cout.tie(0);//scanf("%d",&t);//while(t--){scanf("%d",&n);for(int i=1;i<=n;i++)scanf("%I64d",&a[i]);for(int i=1;i<=n;i++)scanf("%I64d",&b[i]);for(int i=1;i<=n;i++)a[i]=(ll)(n-i+1)*i*a[i];sort(a+1,a+n+1,greater<ll>() );sort(b+1,b+n+1,less<ll>() );for(int i=1;i<=n;i++){ans=(ans+((a[i]%MOD)*b[i]%MOD)%MOD)%MOD;}cout<<ans<<endl;//}#ifdef DEBUGprintf("Time cost : %lf s\n",(double)clock()/CLOCKS_PER_SEC);
#endif//cout << "Hello world!" << endl;return 0;
}
Two Arrays and Sum of Functions相关推荐
- Codeforces数学1600day3[数学CodeForces - 1213D2, CodeForces - 1165E 数论,CodeForces - 1165D 因子分解]
ps:day2太水了不写qwq A - Equalizing by Division (hard version) CodeForces - 1213D2 题目大意:给你n个数和一个k,然后你可以执行 ...
- Lintcode Subarray Sum Closest
Given an integer array, find a subarray with sum closest to zero. Return the indexes of the first nu ...
- 深度学习材料:从感知机到深度网络A Deep Learning Tutorial: From Perceptrons to Deep Networks
In recent years, there's been a resurgence in the field of Artificial Intelligence. It's spread beyo ...
- 吴恩达深度学习课程deeplearning.ai课程作业:Class 1 Week 2 assignment2_1
吴恩达deeplearning.ai课程作业,自己写的答案. 补充说明: 1. 评论中总有人问为什么直接复制这些notebook运行不了?请不要直接复制粘贴,不可能运行通过的,这个只是notebook ...
- Ranklib源码剖析--LambdaMart
Ranklib是一套优秀的Learning to Rank领域的开源实现,其中有实现了MART,RankNet,RankBoost,LambdaMart,Random Forest等模型.其中由微软发 ...
- 吴恩达 深度学习 编程作业(1-2.1)- Python Basics with Numpy
Python Basics with Numpy (optional assignment) Welcome to your first assignment. This exercise gives ...
- 吴恩达 深度学习 编程作业(1-3)- Planar data classification with one hidden layer(平面花形状)
Python Basics with Numpy (optional assignment) Welcome to your first assignment. This exercise gives ...
- 吴恩达深度学习1.2练习_Neural Networks and Deep Learning
版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/weixin_42432468 学习心得: 1.每周的视频课程看一到两遍 2.做笔记 3.做每周的作业 ...
- kotlin_Kotlin阵列
kotlin In this tutorial, we'll look into Kotlin array. If you're a new to Kotlin, it's recommended t ...
最新文章
- SendDlgItemMessage
- Python Numba CPU下加速
- 查看linux是否为虚拟机,以及其它信息,cpu,主机型号,主板型号等
- codeforces731E Funny Game(DP)
- eclipse—安装ADT插件搭建安卓开发环境
- 联想启动Kind City项目:交互式全球合作鼓励同理心,共创建立于善意之上的未来
- 复习简记转发器、网桥、路由器、网关的功能
- GIC spec之ITS和LPI中断1
- 蚂蚁金服 Service Mesh 双十一实战
- mysQL uuID 查询
- 什么是NAT模式、路由模式
- 计算机应用基础实训室,计算机应用基础实训
- 工程流体力学笔记暂记15(理想流体的运动微分方程)
- 百度智能云体验馆领取CDN及24小时急速收录
- 电荷量Q=CU=It=Ne;左右手定则总结+安培定律 2020-3-15
- [AT2442]フェーン現象 (Foehn Phenomena)
- 近期要读的书(经济类)
- 1080P、720P、4CIF、CIF所需要的理论带宽和工程中实际带宽及存储容量
- IDEA中Consolas中文显示不正常
- MySQL下载和安装 win10 64位 MySQL8.0
热门文章
- excel xml mysql_数据库表转换为xml格式,excel转换为xml格式文件
- python单例类命名_单例模式(java/python/c++)
- echarts指针进度条刻度调整_指针式流量开关
- 浅拷贝 python_python中什么是浅拷贝
- php 计算字符串相邻最大重复数_php查找字符串出现次数的方法
- linux重定向多个文件,Linux base shell重定向详解
- word公式插件_添加office小插件,让办公更高效
- 所有的工程师都鄙视 php 工程师.,程序员的鄙视链(所有工程师都鄙视php工程师23333)...
- R中方差,协方差,相关系数
- java定时调度main方法_java相关:Spring中实现定时调度的几种方法