forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 0
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);
}
}