Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define flush cin.ignore(numeric_limits<streamsize>::max(),'\n')
- #define FASTERIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
- #define NL cout<<'\n';
- #define pi acos(-1.0) //3.1415926535897932384626
- #define pb push_back
- #define mk make_pair
- #define mx 1000005
- #define EPS 1e-10
- #define dpoint(x) fixed<<setprecision(x)
- # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
- typedef long long int ll;
- typedef double dl;
- typedef unsigned long long int ull;
- int main() {
- #ifdef anikakash
- clock_t tStart = clock();
- freopen("input.txt", "r", stdin);
- freopen("tmp.txt", "w", stdout);
- #endif
- FASTERIO; //cmt when use scanf & printf ;
- int arr[10], ans[10];
- int cnt = 0;
- bool vis[10];
- int n, x=0; cin >> n;
- for (int i = 0; i < n; i++)cin >> arr[i];
- for (int i = 0; i < 10; i++)vis[i] = false;
- for (int i = 0; i < n - 1; i++) {
- int cnt = 1;
- if (vis[i] == false) {
- for (int j = i + 1; j < n; j++) {
- if (arr[i] == arr[j]) {
- cnt++;
- vis[j] = true;
- }
- }
- if(cnt>1)cout<<arr[i]<<" "<<cnt<<endl;
- ans[x++]=arr[i];
- // cout<<arr[i]<<" ";
- }
- }
- // x--;
- for(int i=0; i<x; i++)cout<<ans[i]<<" ";
- #ifdef anikakash
- fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement