题目链接:http://hhhoj.ngrok.cc/problem/10
非常显而易见,要晚点挂,就要尽可能和菜鸟比,要赢得第
i
场比赛,就要满足是
贴代码
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1100005;
int n,gj,ans;
int a[maxn],b[maxn];
int main(){
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
scanf("%d",&n);
int tt=n-1;
scanf("%d",&gj);
for (int i=1;i<=tt;i++)scanf("%d",&a[i]);
sort(a+1,a+tt+1);
b[1]=a[1];
for (int i=2;i<=tt;i++)b[i]=b[i-1]>a[i]?b[i-1]:a[i];
ans=0;
while (true){
int k=1<<(ans+1);
if (k>n)break;
if (gj>=b[k-1])ans++;else break;
}
printf("%d",ans);
return 0;
}
【写的有漏洞的,欢迎路过大神吐槽】
2017/09/08 22:19:29
Ending.