Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int m,n;
  6. const int ilosc=1000010;
  7. int tab[ilosc];
  8. int MAX=0;
  9. int MIN=0;
  10. int a;
  11.  
  12.  
  13. int main()
  14. {
  15. ios_base::sync_with_stdio(0);
  16.  
  17. cin>>n>>m;
  18.  
  19. for(int i=0;i<m;i++)
  20. {
  21. cin>>a;
  22. if(a==n+1)
  23. {
  24. MIN=MAX;
  25. continue;
  26. }
  27. if(tab[a]<MIN)
  28. {
  29. tab[a]=MIN;
  30. }
  31. tab[a]++;
  32. MAX=max(MAX,tab[a]);
  33. }
  34.  
  35. for(int i=1;i<=n;i++)
  36. {
  37. if(tab[i]<MIN)
  38. {
  39. tab[i]=MIN;
  40. }
  41. cout<<tab[i]<<" ";
  42. }
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement