2024-2-27-730飞行员兄弟.cpp
1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 using namespace std; 6 const int N=100010; 7 int n; 8 int h[N]; 9 10 bool check(int e) 11 { 12 for(int i=1;i<=n;i++) 13 { 14 e=e*2-h[i]; 15 if(e>=1e5) 16 return true; 17 if(e<0) return 0; 18 } 19 return true; 20 } 21 22 int main() 23 { 24 scanf("%d",&n); 25 for(int i=1;i<=n;i++) scanf("%d",&h[i]); 26 int l=0,r=1e5; 27 while(r>l){ 28 int mid=l+r>>1; 29 if(check(mid)) 30 r=mid; 31 else l=mid+1; 32 } 33 printf("%d\n",l); 34 return 0; 35 }
本文来自博客园,作者:{你也不是我的救赎},转载请注明原文链接:https://www.cnblogs.com/pengcai6/articles/18036499