https://codeforc.es/contest/1088/problem/B
模拟即可。
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
priority_queue<int, vector<int>, greater<int> >pq;
int sumsub = 0;
int main() {
#ifdef Yinku
freopen("Yinku.in", "r", stdin);
//freopen("Yinku.out", "w", stdout);
#endif // Yinku
int n, k;
while(~scanf("%d%d", &n, &k)) {
while(!pq.empty())
pq.pop();
for(int i = 1; i <= n; i++) {
int tmp;
scanf("%d", &tmp);
pq.push(tmp);
}
sumsub = 0;
for(int i = 1; i <= k; i++) {
int tmp = 0;
while(!tmp) {
if(pq.empty())
break;
tmp = pq.top() - sumsub;
pq.pop();
}
printf("%d
", tmp);
sumsub += tmp;
}
}
}