题意:
n<=2e5
思路:可以证明答案一定是极长的一段中取最大值
1 #include<cstdio> 2 #include<cstring> 3 #include<string> 4 #include<cmath> 5 #include<iostream> 6 #include<algorithm> 7 #include<map> 8 #include<set> 9 #include<queue> 10 #include<vector> 11 using namespace std; 12 typedef long long ll; 13 typedef unsigned int uint; 14 typedef unsigned long long ull; 15 typedef pair<int,int> PII; 16 typedef vector<int> VI; 17 #define fi first 18 #define se second 19 #define MP make_pair 20 #define N 5100000 21 #define MOD 1e9+7 22 #define eps 1e-8 23 #define pi acos(-1) 24 25 int a[210000],dp[210000],ans,t,w; 26 27 28 29 int read() 30 { 31 int v=0,f=1; 32 char c=getchar(); 33 while(c<48||57<c) {if(c=='-') f=-1; c=getchar();} 34 while(48<=c&&c<=57) v=(v<<3)+v+v+c-48,c=getchar(); 35 return v*f; 36 } 37 38 void swap(int &x,int &y) 39 { 40 int t=x;x=y;y=t; 41 } 42 43 44 45 int main() 46 { 47 // freopen("1.in","r",stdin); 48 // freopen("1.out","w",stdout); 49 int n; 50 scanf("%d",&n); 51 for(int i=1;i<=n;i++) a[i]=read(); 52 53 ans=1; 54 w=1; 55 t=0; 56 dp[1]=1; 57 for(int i=2;i<=n;i++) 58 { 59 dp[i]=1; 60 while(w+1<=n&&a[w]*2<a[i]) w++; 61 while(w+1<i&&w+1<=n&&a[w+1]*2>=a[i]) w++; 62 if(w<i) dp[i]=max(dp[i],dp[w]+1); 63 ans=max(ans,dp[i]); 64 //printf("%d %d %d ",i,w,dp[i]); 65 } 66 printf("%d",ans); 67 return 0; 68 }