forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path5.java
More file actions
29 lines (22 loc) Β· 795 Bytes
/
5.java
File metadata and controls
29 lines (22 loc) Β· 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.*;
public class Main {
public static int n, m;
// 1λΆν° 10κΉμ§μ 무κ²λ₯Ό λ΄μ μ μλ λ°°μ΄
public static int[] arr = new int[11];
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
arr[x] += 1;
}
int result = 0;
// 1λΆν° mκΉμ§μ κ° λ¬΄κ²μ λνμ¬ μ²λ¦¬
for (int i = 1; i <= m; i++) {
n -= arr[i]; // 무κ²κ° iμΈ λ³Όλ§κ³΅μ κ°μ(Aκ° μ νν μ μλ κ°μ) μ μΈ
result += arr[i] * n; // Bκ° μ ννλ κ²½μ°μ μμ κ³±ν΄μ£ΌκΈ°
}
System.out.println(result);
}
}