misschuer

常用链接

统计

积分与排名

百事通

最新评论

Kiki & Little Kiki 1

#include<iostream>
#include
<string>
#include
<set>
using namespace std;

int main()
{
    
    multiset
<int> a;
    
    multiset
<int>::iterator p;
    
    multiset
<int>::iterator it;
    
    
char str[ 5 ];
    
    
int v , t;
    
    
while (scanf ("%d" , &t) != EOF)
    
{
        
        
while (t --)
        
{
            
            scanf (
"%s%d" , str , &v);
            
            
if( str[ 3 ] != '\0')
            
{
                a.insert(v);
                
                
            }

            
            
else
            

                
                it 
= a.find(v);
                
                
if(it != a.end())
                
{
                    printf(
"%d\n" , *it);
                    
                    a.erase(it);
                }

                
                
else
                
{
                    
                    
                    
if(*a.begin() > v)
                    
{
                        printf (
"No Element!\n");
                        
                        
continue;
                    }

                    
                    a.insert(v);
                    
                    it 
= a.find(v);
                    
                    p 
= it;
                    
                    it 
--;
                    
                    printf(
"%d\n",*it);
                    
                    a.erase(p);
                    
                    a.erase(it);
                }

                
            }

        }

        
        a.clear();
        
        printf (
"\n");
    }

    
    
return 23;
    
}

posted on 2009-04-18 10:49 此最相思 阅读(123) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理