#include<stdlib.h> #include<stdio.h> #include<queue> using namespace std; int main(){ int k,n; while(~scanf("%d%d",&n,&k)) { priority_queue<int,vector<int>,greater<int> >q; int t; for(int i=0;i<n;++i) { scanf("%d",&t); q.push(t); } int w=k-1; printf("%d",q.top()); q.pop(); while(w--){ printf(" %d",q.top()); q.pop(); } printf("\n"); } } /************************************************************** Problem: 1371 User: kirchhoff Language: C++ Result: Accepted Time:870 ms Memory:3072 kb ****************************************************************/
STL勉强AC
时间: 2024-12-15 01:38:38