ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 2111. Plato

solution
Posted by Wonsei 19 Sep 2020 04:20
sort the array. maintain W, the total weight of the array.
start from the smallest element and add A[i] * W to ANS.
subtract A[i] from W.
add A[i] * W again.
Re: solution
Posted by Egor 20 Sep 2020 21:49
There is a better solution with O(1) memory and O(n) time (without sorting).

Edited by author 20.09.2020 21:51

Edited by author 20.09.2020 21:51
Re: solution
Posted by Littel_John 5 Nov 2020 16:38
Do you mind sharing this solution?
I solved it using sorting but cannot think of another solution.
Re: solution
Posted by Conformist 3 Dec 2020 15:53
answer = (sum of array) ^ 2
You can get it by simple math.
Littel_John wrote 5 November 2020 16:38
Do you mind sharing this solution?
I solved it using sorting but cannot think of another solution.