显示代码纯文本
#include <cstdio>
using namespace std;
int main(void)
{
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
const int NUM=100000;
int i,j,n,c=-1,tim,temp;
bool hash[200001]={false};
scanf("%d %d\n",&tim,&n);
for (i=0;i<n;i++)
{
scanf("%d\n",&temp);
temp+=NUM;
hash[temp]=true;
}
temp=NUM;
for (i=NUM,j=NUM;tim>=0&&i>=0;i--,j++)
{
if (hash[i])
{
tim-=temp-i;
temp=i;
c++;
}
else if (hash[j])
{
tim-=j-temp;
temp=j;
c++;
}
}
if (tim>=0)
c++;
printf("%d\n",c);
fclose(stdin);
fclose(stdout);
return(0);
}