Submission #9930717
Source Code Expand
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashSet; import java.util.Scanner; public class Main { public static void main(String[] args) { Main main = new Main(); main.solve(); } public void solve() { Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in))); int N = scan.nextInt(); long[] x = new long[N]; for (int i = 0; i < N; i++) { x[i] = scan.nextLong(); } Arrays.sort(x); long ans = 0; for (int i = 1; i <= N; i++) { ans += x[i-1] * (i - 1) - x[i-1] * (N - i); } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | C - Pair Distance |
User | dlmasa |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 750 Byte |
Status | AC |
Exec Time | 505 ms |
Memory | 58168 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 123 ms | 22228 KB |
02.txt | AC | 129 ms | 22612 KB |
03.txt | AC | 165 ms | 25540 KB |
04.txt | AC | 140 ms | 23400 KB |
05.txt | AC | 117 ms | 22612 KB |
06.txt | AC | 171 ms | 25892 KB |
07.txt | AC | 172 ms | 28292 KB |
08.txt | AC | 178 ms | 26504 KB |
09.txt | AC | 176 ms | 28436 KB |
10.txt | AC | 171 ms | 26736 KB |
11.txt | AC | 480 ms | 47964 KB |
12.txt | AC | 480 ms | 44192 KB |
13.txt | AC | 482 ms | 47364 KB |
14.txt | AC | 500 ms | 46212 KB |
15.txt | AC | 452 ms | 52384 KB |
16.txt | AC | 486 ms | 47556 KB |
17.txt | AC | 475 ms | 47728 KB |
18.txt | AC | 492 ms | 55496 KB |
19.txt | AC | 483 ms | 42244 KB |
20.txt | AC | 486 ms | 46548 KB |
21.txt | AC | 467 ms | 50564 KB |
22.txt | AC | 489 ms | 46636 KB |
23.txt | AC | 461 ms | 58168 KB |
24.txt | AC | 505 ms | 48676 KB |
25.txt | AC | 444 ms | 47892 KB |
s1.txt | AC | 91 ms | 21844 KB |
s2.txt | AC | 94 ms | 19284 KB |