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