`
feiliboos
  • 浏览: 659620 次
文章分类
社区版块
存档分类
最新评论

The 36th ACM/ICPC Asia Regional Dalian Site —— Online Contest &&The kth great number

 
阅读更多


http://acm.hdu.edu.cn/showproblem.php?pid=4006


Problem Description
Xiao Ming and Xiao Bao are playing a simple Numbers game. In a round Xiao Ming can choose to write down a number, or ask Xiao Bao what the kth great number is. Because the number written by Xiao Ming is too much, Xiao Bao is feeling giddy. Now, try to help Xiao Bao.


Input
There are several test cases. For each test case, the first line of input contains two positive integer n, k. Then n lines follow. If Xiao Ming choose to write down a number, there will be an " I" followed by a number that Xiao Ming will write down. If Xiao Ming choose to ask Xiao Bao, there will be a "Q", then you need to output the kth great number.



Output
The output consists of one integer representing the largest number of islands that all lie on one line.



Sample Input
8 3
I 1
I 2
I 3
Q
I 5
Q
I 4
Q


Sample Output
1
2
3
这道题有点下技巧,就是用了STL中multiset容器,可以自动从小到大排序,而且可以允许每次都插入相同的元素,还有就是每次要保证容器中有k个元素,

代码1:


代码二:



分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics