Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. /******************************************************************************
  2.  
  3. Online C++ Compiler.
  4. Code, Compile, Run and Debug C++ program online.
  5. Write your code in this editor and press "Run" button to compile and execute it.
  6.  
  7. *******************************************************************************/
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. int n, k, m, f = 1, x = 1000, w = 1, t = 0, max = 0 , l;
  16. cin>>n;
  17. cin>>k;
  18. int a[1000];
  19. int b[1000];
  20. int c[1000];
  21. for(int i = 0; i < n; i++)
  22. {
  23. a[i] = 0;
  24. b[i] = 0;
  25. }
  26. for(int i = 0;i < n; i++)
  27. {
  28. cin>>m;
  29. if(a[m-1] == 0)
  30. {
  31. c[t] = m-1;
  32. t++;
  33. }
  34. a[m-1]++;
  35.  
  36. }
  37. for(int i = 0; i < n; i++)
  38. {
  39. if(max < a[i])
  40. {
  41. max = a[i];
  42. }
  43. }
  44. for(int i = 0; i < 100; i++)
  45. {
  46. if(a[i] == max)
  47. {
  48. l++;
  49. }
  50. }
  51. if(f == 1)
  52. {
  53. while (x > 0)
  54. {
  55. for(int i = 0; i < n; i++)
  56. {
  57. if (a[i] == x)
  58. {
  59. for(int j = 0; j < x; j++)
  60. {
  61. b[(k*w)-1] = i;
  62. k++;
  63. cout<<b[i];
  64. }
  65. }
  66. }
  67. x--;
  68. }
  69. }
  70. else
  71. {
  72. cout<<-1;
  73. }
  74. cout<<endl;
  75. for(int i = 0; i < n; i++)
  76. {
  77. cout<<b[i];
  78.  
  79. }
  80. cout<<endl;
  81. for(int i = 0; i < n; i++)
  82. {
  83. cout<<a[i];
  84.  
  85. }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement