当前位置:网站首页>[acwing] 58 weeks 4489 Longest subsequence
[acwing] 58 weeks 4489 Longest subsequence
2022-07-04 17:01:00 【*DDL_ GzmBlog】
Preface
t a g : tag : tag: thinking
Portal :
The question :
Given a rising Array of , Find a subsequence so that the elements in the subsequence meet a j ∗ 2 ≥ a j + 1 a_j*2\ge a_{j+1} aj∗2≥aj+1, Ask about the sequence of legitimate subsequences Maximum length
Ideas :
Because the given array is ascendant
So if a 1 ∗ 2 ≥ a 3 a_1*2\ge a_3 a1∗2≥a3 There is , Then there must be a 1 ∗ 2 ≥ a 2 a_1 *2\ge a_2 a1∗2≥a2
Then this condition makes the answer continuity , So we just need O n On On Just sweep it once
code :
#include <iostream>
#include <vector>
#include <map>
#include <cstring>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <algorithm>
using namespace std;
#define IOS ios::sync_with_stdio(false);
#define CIT cin.tie(0);
#define COT cout.tie(0);
#define ll long long
#define x first
#define y second
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),x.end()
#define Fup(i,a,b) for(int i=a;i<=b;i++)
#define Fde(i,a,b) for(int i=a;i>=b;i--)
#define cer(a) cerr<<#a<<'='<<(a)<<" @ line "<<__LINE__<<" "<<endl
typedef priority_queue<int,vector<int>,greater<int>> Pri_m;
typedef pair<int,int> pii;
typedef vector<int> VI;
map<int,int> mp;
const int N = 2e5+10,INF = 0x3f3f3f3f;
const double eps = 1e-5;
struct node{
int to,val;
};
int a[N],st[N];
int n,i;
void solve(){
cin>>n;
int ans = -INF;
Fup(i,1,n) cin>>a[i];
int res = 1;
Fup(i,1,n-1){
if(a[i]*2 >= a[i+1]) res++;
else res = 1;
ans = max(ans,res);
}
cout<<ans<<endl;
// Fup(i,1,n-1) if(a[i]*2 >= a[i+1]) st[i] = 1;
// Fup(i,1,n-1){
// if( !st[i] ) continue;
// int res = 1;
// while(st[i]) i ++ , res++;
// ans = max(res,ans);
// }
// if(ans < 0 ) cout<<1<<endl;
// else cout<<ans<<endl;
}
int main(){
//int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- China's roof ladder market trend report, technological innovation and market forecast
- 科普达人丨一文看懂阿里云的秘密武器“神龙架构”
- 多年锤炼,迈向Kata 3.0 !走进开箱即用的安全容器体验之旅| 龙蜥技术
- 新的职业已经出现,怎么能够停滞不前 ,人社部公布建筑新职业
- 容器环境minor gc异常频繁分析
- Understand asp Net core - Authentication Based on jwtbearer
- Visual studio 2019 (localdb) mssqllocaldb SQL Server 2014 database version is 852 and cannot be opened. This server supports 782
- S2b2b solution for lighting industry: efficiently enable the industrial supply chain and improve the economic benefits of enterprises
- 安信证券手机版下载 网上开户安全吗
- Is it safe to open an account online
猜你喜欢
Statistical learning: logistic regression and cross entropy loss (pytoch Implementation)
Smart Logistics Park supply chain management system solution: digital intelligent supply chain enables a new supply chain model for the logistics transportation industry
Cut! 39 year old Ali P9, saved 150million
Detailed process of DC-2 range construction and penetration practice (DC range Series)
Years of training, towards Kata 3.0! Enter the safe container experience out of the box | dragon lizard Technology
祝贺Artefact首席数据科学家张鹏飞先生荣获 Campaign Asia Tech MVP 2022
[North Asia data recovery] a database data recovery case where the disk on which the database is located is unrecognized due to the RAID disk failure of HP DL380 server
~88 running people practice
照明行业S2B2B解决方案:高效赋能产业供应链,提升企业经济效益
周大福践行「百周年承诺」,真诚服务推动绿色环保
随机推荐
C implementation defines a set of intermediate SQL statements that can be executed across libraries
Research Report on market supply and demand and strategy of tetramethylpyrazine industry in China
Statistical learning: logistic regression and cross entropy loss (pytoch Implementation)
[Acwing] 58周赛 4490. 染色
Accounting regulations and professional ethics [6]
Blood spitting finishing nanny level series tutorial - play Fiddler bag grabbing tutorial (2) - first meet fiddler, let you have a rational understanding
Maximum subarray and matrix multiplication
周大福践行「百周年承诺」,真诚服务推动绿色环保
. Net applications consider x64 generation
昆明三环闭合工程将经过这些地方,有在你家附近的吗?
China tall oil fatty acid market trend report, technical dynamic innovation and market forecast
Solution du système de gestion de la chaîne d'approvisionnement du parc logistique intelligent
被PMP考试“折磨”出来的考试心得,值得你一览
矿产行业商业供应链协同系统解决方案:构建数智化供应链平台,保障矿产资源安全供应
实战:fabric 用户证书吊销操作流程
L1-072 scratch lottery
Readis configuration and optimization of NoSQL (final chapter)
线性时间排序
Accounting regulations and professional ethics [8]
Research Report of exoskeleton robot industry - market status analysis and development prospect prediction