#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=100+5;
int vis[maxn];
int abs(int x) {return x>0?x:-x;}
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
memset(vis,0,sizeof(vis));
int first,x;
scanf("%d",&first);
for(int i=2;i<=n;i++) {scanf("%d",&x);vis[abs(x)]=(x>0)?1:-1;}
int d=(first>0)?1:-1;
first=abs(first);
int cnt=0;
if(d>0)
{
int mind=10000;
for(int i=first;i<=100;i++)
{
if(vis[i]!=0&&first+d*100>i+vis[i]*100) {cnt++;mind=min(mind,i+vis[i]*100);}
}
for(int i=1;i<first;i++)
{
if(vis[i]!=0&&i+vis[i]*100>mind) cnt++;
}
}
else{
int maxd=-10000;
for(int i=1;i<first;i++)
{
if(vis[i]!=0&&i+100*vis[i]>first+d*100) {cnt++;maxd=max(maxd,i+100*vis[i]);}
}
for(int i=first;i<=100;i++)
{
if(vis[i]!=0&&i+100*vis[i]<maxd) cnt++;
}
}
cout<<cnt+1<<endl;
}
}
NYOJ 990 蚂蚁感冒(模拟)
最新推荐文章于 2017-04-06 15:16:12 发布