Advertisement
Saleh127

CF 569B

Sep 29th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll a[100005],c[100005]={0},d,e,f=1,i,j,k,l;
  11.  
  12. cin>>d;
  13. for(i=0;i<d;i++)
  14. {
  15. cin>>a[i];
  16. c[a[i]]++;
  17. }
  18. for(i=0;i<d;i++)
  19. {
  20. if(c[a[i]]==1 && a[i]<=d)
  21. {
  22. cout<<a[i]<<" ";
  23. }
  24. else
  25. {
  26. while(c[f])
  27. {
  28. f++;
  29. }
  30. cout<<f<<" ";
  31. c[f]++;
  32. c[a[i]]--;
  33. }
  34. }
  35. cout<<endl;
  36. return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement