272일차 - BOJ no.16208

https://www.acmicpc.net/problem/16208

My Solution

import sys

n = sys.stdin.readline().rstrip()
arr = list(map(int, sys.stdin.readline().rstrip().split()))

arr.sort()
tot = sum(arr)
result = 0
for i in arr:
    result += i * (tot - i)
    tot -= i
print(result)

좋은 웹페이지 즐겨찾기