AcWing 4489. 最长子序列
原题链接
中等
作者:
123_
,
2022-07-02 20:44:09
,
所有人可见
,
阅读 171
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <map>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
using namespace std;
#define lowbit(x) x & -x
typedef long long ll;
void solve()
{
int n, x;
stack<int> s;
cin >> n;
int len = 1;
for (int i = 1; i <= n; i ++)
{
cin >> x;
if (!s.empty()){
while (s.top() * 2 < x){
s.pop();
if (s.empty())
break;
}
}
s.push(x);
len = max(len, (int)s.size());
}
cout << len << "\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
solve();
return 0;
}