标签:
寻找大富翁
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4574 Accepted Submission(s): 1857
1 #include <queue> 2 #include <cstdio> 3 #include <iostream> 4 using namespace std; 5 int main() 6 { 7 int n, m, i, p; 8 9 while(~scanf("%d %d", &n, &m), m+n) 10 { 11 12 priority_queue<int, vector<int>, less<int> >q; 13 for(i=0; i<n; i++) 14 { 15 scanf("%d", &p); 16 q.push(p); 17 } 18 printf("%d",q.top()); 19 q.pop(); 20 int total = 1; 21 while(!q.empty()) 22 { 23 if(total == m) 24 break; 25 printf(" %d",q.top()); 26 q.pop(); 27 total++; 28 } 29 printf("\n"); 30 31 } 32 return 0; 33 }
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4684307.html