1 solutions
-
0
#include <iostream> #include <bits/stdc++.h> using namespace std; struct number{ int id; int num; }pp[10005]; int main() { int a[10005]; int n; cin >> n; for(int i = 1 ;i <= n ;i++){ cin >> a[i]; } sort(a + 1 ,a + 1 + n); pp[1].id = a[1]; pp[1].num = 1; int j = 2; for(int i = 2 ;i <= n ;i++){ if(a[i] != a[i - 1]){ pp[j].id = a[i]; pp[j].num = 1; j++; }else{ pp[j-1].num++; } } for(int k = 1 ;k < j ;k++){ cout << pp[k].id << " " <<pp[k].num << "\n"; } return 0; }
- 1
Information
- ID
- 1758
- Time
- 1000ms
- Memory
- 512MiB
- Difficulty
- 10
- Tags
- # Submissions
- 2
- Accepted
- 2
- Uploaded By