首页 > 其他 > 详细

UVALive 7595

时间:2017-08-31 21:55:05      阅读:259      评论:0      收藏:0      [点我收藏+]

明天集训结束......!

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
map<int,int> flag;
int n,x;
int main()
{  int ceng=1,sum=0;//深度,点的数量
    scanf("%d",&n);
     while(n--)
     {
       scanf("%d",&x);
        if(x<ceng)//小于这个深度不行,已经被占用
        {
          printf("No\n");
          continue;
        }
         printf("Yes\n");
        while(x>=0&&flag[x])//两点合成它们上面的点
        {
             flag[x]=0;
             sum--;//点的数量减少一个
             x--;
        }
       sum++;
       flag[x]=1;//标记找到的最上面的点
        if(ceng<5e5+10)
        {
             while(flag[ceng])
                ceng++;//更新深度
        }
         ceng=min(ceng,sum);//如sum为1,层为2,x=1也成立,故取最小
       if(!x) ceng=1e9+100;//全部占满,则都不再成立
     }
    return 0;
}

 

UVALive 7595

原文:http://www.cnblogs.com/Wangwanxiang/p/7460704.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!