Advertisement
Anik_Akash

delete copy value

Oct 7th, 2021
560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace    std;
  3.  
  4. #define flush                    cin.ignore(numeric_limits<streamsize>::max(),'\n')
  5. #define FASTERIO                 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  6. #define NL                       cout<<'\n';
  7. #define pi                       acos(-1.0) //3.1415926535897932384626
  8. #define pb                       push_back
  9. #define mk                       make_pair
  10. #define mx                       1000005
  11. #define EPS                      1e-10
  12. #define dpoint(x)                fixed<<setprecision(x)
  13. # define my_sizeof(type) ((char *)(&type+1)-(char*)(&type))
  14. typedef long long int            ll;
  15. typedef double                   dl;
  16. typedef unsigned long long int   ull;
  17.  
  18. int main() {
  19.  
  20. #ifdef anikakash
  21.     clock_t tStart = clock();
  22.     freopen("input.txt", "r", stdin);
  23.     freopen("tmp.txt", "w", stdout);
  24. #endif
  25.  
  26.     FASTERIO; //cmt when use scanf & printf ;
  27.  
  28.     int arr[10], ans[10];
  29.     int cnt = 0;
  30.     bool vis[10];
  31.     int n, x=0; cin >> n;
  32.  
  33.     for (int i = 0; i < n; i++)cin >> arr[i];
  34.     for (int i = 0; i < 10; i++)vis[i] = false;
  35.  
  36.     for (int i = 0; i < n - 1; i++) {
  37.         int cnt = 1;
  38.         if (vis[i] == false) {
  39.             for (int j = i + 1; j < n; j++) {
  40.                 if (arr[i] == arr[j]) {
  41.                     cnt++;
  42.                     vis[j] = true;
  43.                 }
  44.             }
  45.             if(cnt>1)cout<<arr[i]<<" "<<cnt<<endl;
  46.             ans[x++]=arr[i];
  47.             // cout<<arr[i]<<" ";
  48.         }
  49.     }
  50.     // x--;
  51.     for(int i=0; i<x; i++)cout<<ans[i]<<" ";
  52.  
  53.  
  54. #ifdef anikakash
  55.     fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  56. #endif
  57.  
  58.     return 0;
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement