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

Wonsei solution [3] // Problem 2111. Plato 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.
Egor Re: solution [2] // Problem 2111. Plato 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
Littel_John Re: solution [1] // Problem 2111. Plato 5 Nov 2020 16:38
Do you mind sharing this solution?
I solved it using sorting but cannot think of another solution.
Conformist Re: solution // Problem 2111. Plato 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.