Ehab and subtraction
阿新 • • 發佈:2018-12-06
https://codeforces.com/contest/1088/problem/B
/* *@Author: STZG *@Language: C++ */ #include <bits/stdc++.h> #include<iostream> #include<algorithm> #include<cstdlib> #include<cstring> #include<cstdio> #include<string> #include<vector> #include<bitset> #include<queue> #include<deque> #include<stack> #include<cmath> #include<list> #include<map> #include<set> //#define DEBUG using namespace std; typedef long long ll; const int N=100000+10; const double PI = acos(-1.0); const double EXP = 1E-8; const int INF = 0x3f3f3f3f; int t,n,m,k; int a[N]; int main() { #ifdef DEBUG freopen("input.in", "r", stdin); //freopen("output.out", "w", stdout); #endif ios::sync_with_stdio(false); scanf("%d%d",&n,&k); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } sort(a+1,a+n+1); ll sum=0; int cnt=0; for(int i=1;i<=n&&cnt<k;i++){ if(a[i]-sum>0){ cout << a[i]-sum << endl; sum=a[i]; cnt++; } } for(int i=cnt+1;i<=k;i++){ cout << 0<< endl; } //cout << "Hello world!" << endl; return 0; }