forked from ndb796/python-for-coding-test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path5.cpp
More file actions
27 lines (20 loc) · 592 Bytes
/
5.cpp
File metadata and controls
27 lines (20 loc) · 592 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
#include <bits/stdc++.h>
using namespace std;
int n, m;
// 1부터 10까지의 무게를 담을 수 있는 배열
int arr[11];
int main(void) {
cin >> n >> m;
for (int i = 0; i < n; i++) {
int x;
cin >> x;
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가 선택하는 경우의 수와 곱해주기
}
cout << result << '\n';
}