Advertisement
erfanul007

Untitled

Jan 13th, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long int ll;
  5. typedef unsigned long long int ull;
  6. typedef vector<int> vi;
  7. typedef vector<ll> vll;
  8. typedef vector<vi> vvi;
  9. typedef pair<int,int> pii;
  10. typedef vector< pii > vpii;
  11. typedef set<int> sti;
  12.  
  13. #define pb push_back
  14. #define pob pop_back
  15. #define mp make_pair
  16. #define ff first
  17. #define ss second
  18. #define loop1(i,n) for(int i=1; i<=int(n); i++)
  19. #define loop(i,y) for(int i=0; i<int(y); i++)
  20. #define rloop(i,y) for(int i=int(y); i>0; i--)
  21. #define rloop1(i,y) for(int i=int(y)-1; i>=0; i--)
  22. #define read() freopen("input.txt", "r", stdin)
  23. #define write() freopen("output.txt", "w", stdout)
  24. #define cspf(i) printf("Case %d: ", i)
  25. #define all(v) v.begin(),v.end()
  26. /// Constants
  27. #define eps 1e-9
  28. #define PI acos(-1.0) // 3.1415926535897932
  29.  
  30. #include<stdio.h>
  31. #include<math.h>
  32. int main()
  33. {
  34. ll n,k,x;
  35. cin>>n>>k;
  36. vll v(n);
  37. loop(i,n)
  38. cin>>v[i];
  39. sort(all(v));
  40. ll sum=0,j=0;
  41. loop(i,k){
  42. if(j<n){
  43. while(j+1<n && v[j]-sum<=0)
  44. j++;
  45. x=v[j]-sum;
  46. if(x<0)
  47. x=0;
  48. cout<<x<<endl;
  49. sum+=x;
  50. }
  51. else
  52. cout<<"0"<<endl;
  53. j++;
  54. }
  55. return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement