Submission #19724147


Source Code Expand

Copy
import sys
input=sys.stdin.readline
N=int(input())
A=list(map(int,input().split()))
A.sort()
sum_num=0
for i in range(N):
    sum_num+=i*A[i] - (N-1-i)*A[i]
print(sum_num)

Submission Info

Submission Time
Task D - Sum of difference
User tokumaru_y
Language Python (3.8.2)
Score 400
Code Size 179 Byte
Status AC
Exec Time 196 ms
Memory 30944 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 25
Set Name Test Cases
Sample sample_01.txt, sample_02.txt
All hand_01.txt, max_01.txt, max_02.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
hand_01.txt AC 24 ms 9036 KB
max_01.txt AC 164 ms 30824 KB
max_02.txt AC 137 ms 30704 KB
random_01.txt AC 196 ms 30804 KB
random_02.txt AC 184 ms 30692 KB
random_03.txt AC 186 ms 30804 KB
random_04.txt AC 188 ms 30828 KB
random_05.txt AC 183 ms 30912 KB
random_06.txt AC 188 ms 30692 KB
random_07.txt AC 186 ms 30832 KB
random_08.txt AC 185 ms 30696 KB
random_09.txt AC 186 ms 30848 KB
random_10.txt AC 184 ms 30792 KB
random_11.txt AC 189 ms 30832 KB
random_12.txt AC 186 ms 30688 KB
random_13.txt AC 179 ms 30916 KB
random_14.txt AC 183 ms 30688 KB
random_15.txt AC 179 ms 30764 KB
random_16.txt AC 181 ms 30788 KB
random_17.txt AC 187 ms 30944 KB
random_18.txt AC 188 ms 30912 KB
random_19.txt AC 187 ms 30688 KB
random_20.txt AC 185 ms 30700 KB
sample_01.txt AC 20 ms 8920 KB
sample_02.txt AC 28 ms 9000 KB