Guest User

Untitled

a guest
Dec 4th, 2018
3,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include <iostream>
  2. #include <set>
  3. using namespace std;
  4. int main()
  5. {
  6.     int n,m;
  7.     scanf("%d%d",&n,&m);
  8.     set<int> s;
  9.     s.insert(0);
  10.     while (n--)
  11.     {
  12.         int a;
  13.         scanf("%d",&a);
  14.         s.insert(a);
  15.     }
  16.     auto it=s.begin();
  17.     for (int i=0;i<m;i++)
  18.     {
  19.         if (next(it)==s.end())
  20.         printf("0\n");
  21.         else
  22.         {
  23.             printf("%d\n",*next(it)-*it);
  24.             it=next(it);
  25.         }
  26.     }
  27. }
Add Comment
Please, Sign In to add comment