Codeforces Round #623 (Div. 2, based on VK Cup 2019-2020 - Elimina F. Moving Points (树状数组)

该博客介绍了如何使用树状数组解决一个关于点在坐标轴上移动,求所有点对之间最小距离之和的问题。题目给出了点的数量、初始坐标和速度,并提供了样例输入输出。思路是通过分析点的速度来确定何时距离会变小,并利用树状数组进行高效处理。
摘要由CSDN通过智能技术生成

F. Moving Points
time limit per test2 seconds
memory limit per test256 megabytes

inputstandard input
outputstandard output

There are n points on a coordinate axis OX. The i-th point is located at the integer point xi and has a speed vi. It is guaranteed that no two points occupy the same coordinate. All n points move with the constant speed, the coordinate of the i-th point at the moment t (t can be non-integer) is calculated as xi+t⋅vi.

Consider two points i and j. Let d(i,j) be the minimum possible distance between these two points over any possible moments of time (even non-integer). It means that if two points i and j coincide at some moment, the value d(i,j) will be 0.

Your task is to calculate the value ∑1≤i<j≤n d(i,j) (the sum of minimum distances over all pairs of points).

Input
The first line of the input contains one integer n (2≤n≤2⋅105) — the number of po

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值