好几天没写题了,总是因为各种各样的借口。。。鄙视自己。。
前几天一个中大毕业、生前就职百度的师兄居然熬夜敲代码敲死了。。表示以后再也不要轻易熬夜了。默哀
/*
zoj_3519 贪心
很水的一道题,居然还wa了一次。。
方法:直接从小到大排下序,当前比ip小的不管怎样都是使ip加1的,而要使当前ip最小(这样才有更大的机会加2)
这些加1的肯定要放到后来才加。所以下一场比赛应该是曹操和智力最接近他且比他高的人比赛。依此贪心取
下去。
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int IQ[510];
int main()
{
int n,ip,i;
int count;
while( scanf("%d%d",&n,&ip)!=EOF )
{
for( i=0;i<n;i++ )
scanf( "%d",&IQ[i] );
sort(IQ,IQ+n);
i=0 , count=0;
while( i<n )
{
while( IQ[i]<=ip && i<n ) //居然忘加i<n导致一次wa,一定要注意细节啊!
count++,i++;
if( i<n ) ip+=2,i++;
}
printf( "%d\n",ip+count );
}
return 0;
}