Another Solution For Last Round Div.2 D

Правка en1, от xcx0902, 2024-02-12 10:49:30

Consider checking $$$k$$$ one by one. Let $$$sq$$$ be $$$\sum_{i=1}^n a_i$$$. For each $$$k \le sq$$$, calculate the strength in $$$O(n)$$$. For the other $$$k$$$, pre-calculate the contribution of $$$c_i \le sq$$$ (their contribution won't change when $$$k > sq$$$). Then we calculate each $$$c_i > sq$$$ (At most $$$sq$$$ occupation of $$$c_i$$$ that $$$c_i > sq$$$). So the total complexity is $$$O(n \cdot sq)$$$.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский xcx0902 2024-02-12 10:49:30 404 Initial revision (published)