标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65768/65768 K (Java/Others)
Total Submission(s): 8312 Accepted Submission(s): 3283
1 #include <queue> 2 #include <cstdio> 3 #include <iostream> 4 using namespace std; 5 int main() 6 { 7 int n, t; 8 while(~scanf("%d %d", &n, &t)) 9 { 10 priority_queue <int, vector<int>, greater<int> >q; 11 char ch[2]; int num; 12 while(n--) 13 { 14 scanf("%s", &ch); 15 if(ch[0] == ‘I‘) 16 { 17 scanf("%d", &num); 18 if(q.size() < t) //队列未满; 19 q.push(num); 20 else if(num > q.top()) //队头元素较小; 21 { 22 q.pop(); 23 q.push(num); 24 } 25 } 26 else 27 printf("%d\n", q.top()); 28 } 29 } 30 return 0; 31 } 32
标签:
原文地址:http://www.cnblogs.com/fengshun/p/4684348.html