BZOJ2456-mode题解--一道有趣题

  • 题目链接:

    https://www.lydsy.com/JudgeOnline/problem.php?id=2456

  • 瞎扯

    这是今天考的模拟赛T2交互题的一个30分部分分,老师在讲题时提到了这题。考场上我比较菜并没有想出来

  • 分析:

    一个非常神奇美妙的做法,请大家直接看代码

include

include

template inline void read(T &x){
x=0;int ne=0;char c;
while(!isdigit(c=getchar()))ne=c'-';
x=c-48;
while(isdigit(c=getchar()))x=(x<<3)+(x<<1)+c-48;
x=ne?-x:x;
return ;
}
int n,x,y=-0x7fffffff,tot=0;
int main(){
scanf("%d\n",&n);
while(n--){
read(x);
if(x
y){
tot++;
}
else if(!tot){
y=x,tot=1;
}
else tot--;
}
printf("%d\n",y);
return 0;
}

posted @ 2018-07-05 23:40  Rye_Catcher  阅读(260)  评论(0编辑  收藏  举报