• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            coreBugZJ

            此 blog 已棄。

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

            The kth great number

            Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others)

            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

            Hint
            Xiao Ming won't ask Xiao Bao the kth great number when the number of the written number is smaller than k. (1=<k<=n<=1000000).
             


            打個醬油。
            小根堆保存最多 K 個元素,對每次詢問輸出堆頂元素。



             1 #include <iostream>
             2 #include <cstdio>
             3 #include <algorithm>
             4 #include <queue>
             5 
             6 using namespace std;
             7 
             8 typedef  priority_queue< int, vector< int >, greater< int > >  Heap;
             9 
            10 int main() {
            11         Heap mh;
            12         int n, k, x;
            13         char cmd[ 3 ];
            14         while ( 2 == scanf( "%d%d"&n, &k ) ) {
            15                 while ( ! mh.empty() ) {
            16                         mh.pop();
            17                 }
            18                 while ( n-- > 0 ) {
            19                         scanf( "%s", cmd );
            20                         if ( 'I' == cmd[ 0 ] ) {
            21                                 scanf( "%d"&x );
            22                                 mh.push( x );
            23                                 while ( mh.size() > k ) {
            24                                         mh.pop();
            25                                 }
            26                         }
            27                         else {
            28                                 printf( "%d\n", mh.top() );
            29                         }
            30                 }
            31         }
            32         return 0;
            33 }
            34 

            posted on 2011-09-03 18:17 coreBugZJ 閱讀(362) 評論(0)  編輯 收藏 引用 所屬分類: ACM

            久久人人爽人人爽人人片av麻烦| 狠狠色丁香久久婷婷综合五月 | 久久综合偷偷噜噜噜色| 一本一本久久a久久精品综合麻豆| 久久久无码精品亚洲日韩京东传媒| 亚洲а∨天堂久久精品| 亚洲AV无码久久精品蜜桃| 青青青伊人色综合久久| 午夜精品久久久内射近拍高清| 一本综合久久国产二区| 久久无码av三级| 久久免费看黄a级毛片| 品成人欧美大片久久国产欧美| 久久久国产99久久国产一| 成人久久综合网| 国产精品99久久久久久宅男小说| 久久国产乱子伦免费精品| 精品久久人人做人人爽综合| 性做久久久久久久| 久久精品国产色蜜蜜麻豆| 国产精品一区二区久久精品| 久久精品国产免费观看| 久久亚洲高清综合| 狠狠色综合网站久久久久久久| 久久亚洲精品人成综合网| 久久无码高潮喷水| 久久综合一区二区无码| 日本久久久久久中文字幕| 国产精品99精品久久免费| 伊人久久综合无码成人网| 久久99这里只有精品国产| 久久久噜噜噜久久| 久久久久99精品成人片三人毛片| 亚洲狠狠综合久久| 亚洲午夜精品久久久久久人妖| 久久99中文字幕久久| 国产精品久久久久aaaa| 国产精品久久影院| 国内精品久久久久影院免费| 久久精品中文字幕久久| 久久精品国产国产精品四凭|