Kiki & Little Kiki 1

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;
    
}

你可能感兴趣的:(Kiki & Little Kiki 1)