codeforces-379B. New Year Present

codeforces-379B. New Year Present



5609242 Jan 3, 2014 12:30:05 PM 20114045007 379B - New Year Present GNU C++ Happy New Year! 15 ms 100 KB

#include
#include
using namespace std;
int main()
{
    int n,a;
    int i,j;
    mapma;
    scanf("%d",&n);
    for(i=0; i0)
            ma[i]=a;
    }
    map::iterator it=ma.begin(),it1;
    i=0;
    while(!ma.empty())
    {
        for(j=i; jfirst; j++)printf("R");
        for(j=it->first; jsecond--;
        i=it->first;
        it1=it;
        if(ma.size()>1&&it!=ma.begin()) it--;
        else if(ma.size()>1)it++;
        if(it1->second==0)ma.erase(it1->first);
        if(ma.size()==1)
        {
            it=ma.begin();
            if(i!=it->first)
            {
                for(j=i; jfirst; j++)printf("R");
                for(j=it->first; jsecond--;
            }
            if(it->first>0)
                for(j=0; jsecond; j++)printf("LRP");
            else
                for(j=0; jsecond; j++)printf("RLP");
            break;
        }
    }
    printf("\n");
    return 0;
}




你可能感兴趣的:(库函数运用,活跃思维)