Rotating Lines

시간 제한3초메모리 제한2048 MB

요약
n개의 막대 각도가 정수 v[i] (0~49999)로 주어질 때, 여러 막대를 같은 각도로 동시에 회전시키되 전체 에너지 효율이 감소하지 않도록 하고 총 선택 횟수 2,000,000 예산 안에서 모든 쌍의 예각 합을 최대화합니다.
난이도

어려움10점 중 8점

유형
수학, 그리디, 정렬, 투 포인터
정답자
아직 제출이 없습니다

문제

Asadullo is an outstanding researcher at APIO (Alliance for Power and Industrial Optimization). Recently, he has been studying a method to generate energy using an unknown material.

This unknown material does not produce energy on its own, but if there are several extremely long rods made of this material, they can generate energy through their interactions.

Specifically, there are nn rods, given by an array v\[0],v\[1],…,v\[n−1]v\[0], v\[1], \dots , v\[n − 1]. The ii-th rod can be positioned at an angle of a\[i]=360⋅v\[i]100000∘a\[i] = 360 \cdot \frac{v\[i]}{100000}^\circ, with respect to the positive direction of the x-axis, in counterclockwise. The energy efficiency by these nn rods is defined as ∑_i<jacute(i,j)\displaystyle\sum\_{i < j}{\text{acute}(i, j)} where acute(i,j)\text{acute}(i, j) represents the acute angle formed between the ii-th rod and the jj-th rod. In this problem, we consider 90∘90^\circ as an acute angle.

More formally, acute(i,j)=min⁡(v\[i]−v\[j],50000−v\[i]−v\[j])\text{acute}(i, j) = \min( v\[i] − v\[j] , 50000 − v\[i] − v\[j] ).

In other words, the energy efficiency is calculated by adding the acute angles between every pair of rods.For example, if v=\[5000,12500,37500]v = \[5000, 12500, 37500] and correspondingly, a=\[18,45,135]a = \[18, 45, 135], we would get the following graph:

Here, acute(0,1)=7500\text{acute}(0, 1) = 7500 (i.e. 27∘27^\circ), acute(0,2)=17500\text{acute}(0, 2) = 17500 (i.e. 63∘63^\circ), and acute(1,2)=25000\text{acute}(1, 2) = 25000 (i.e. 90∘90^\circ). Therefore, the energy efficiency of these rods equals 7500+17500+25000=500007500 + 17500 + 25000 = 50000.

Asadullo wants to adjust the arrangement of these n rods to maximize their energy efficiency. However, there are several constraints:

  • First, since this material is extremely hazardous to living beings, the rods can only be rotated using a specialized mechanical device in a controlled manner. This device allows selecting multiple rods at once and rotating them by the same angle simultaneously.
  • Asadullo does not want the energy efficiency of the rods to decrease. Therefore, after any operation using the device, the energy efficiency must not be lower than before.
  • Since operating the device consumes a large amount of energy, the total number of rods selected across all operations must not exceed 2,000,0002\\, 000\\, 000.

Under these constraints, Asadullo wants to perform operations optimally to maximize the energy efficiency of the rods. Write a program to help Asadullo achieve the highest possible energy efficiency.

제한

  • 2≤n≤100,0002 ≤ n ≤ 100\\, 000
  • 0≤v\[i]≤49,9990 ≤ v\[i] ≤ 49\\, 999 for each 0≤i<n0 ≤ i < n
  • elements of vv are not necessarily distinct

예제

이 문제는 공개된 예제가 없습니다.