日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

CodeForces - 1029B.Creating the Contest(最长上升子序列0(n)解法)

發布時間:2025/3/18 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 CodeForces - 1029B.Creating the Contest(最长上升子序列0(n)解法) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

思路:這道題無法用平時0(n^2)的解法來求最長上升子序列,會超時,只能用優化的最長上升子序列算法來求

You are given a problemset consisting of nn problems. The difficulty of the ii -th problem is aiai . It is guaranteed that all difficulties are distinct and are given in the increasing order.

You have to assemble the contest which consists of some problems of the given problemset. In other words, the contest you have to assemble should be a subset of problems (not necessary consecutive) of the given problemset. There is only one condition that should be satisfied: for each problem but the hardest one (the problem with the maximum difficulty) there should be a problem with the difficulty greater than the difficulty of this problem but not greater than twice the difficulty of this problem. In other words, let ai1,ai2,,aipai1,ai2,…,aip be the difficulties of the selected problems in increasing order. Then for each jj from 11 to p?1p?1 aij+1aij?2aij+1≤aij?2 should hold. It means that the contest consisting of only one problem is always valid.

Among all contests satisfying the condition above you have to assemble one with the maximum number of problems. Your task is to find this number of problems.

Input

The first line of the input contains one integer nn (1n2?1051≤n≤2?105 ) — the number of problems in the problemset.

The second line of the input contains nn integers a1,a2,,ana1,a2,…,an (1ai1091≤ai≤109 ) — difficulties of the problems. It is guaranteed that difficulties of the problems are distinct and are given in the increasing order.

Output

Print a single integer — maximum number of problems in the contest satisfying the condition in the problem statement.

Examples

Input 10
1 2 5 6 7 10 21 23 24 49 Output 4 Input 5
2 10 50 110 250 Output 1 Input 6
4 7 12 100 150 199 Output 3 #include <cstdio> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <queue>using namespace std;int n, a[200000+8], dp[200000+8];int main() {scanf("%d", &n);for(int i = 0; i<n; i++)scanf("%d", &a[i]);int ans = 1;//尋求最優的結果dp[1] = 1;//一開始設最長上升子序列的1for(int i = 0; i<n; i++){if(a[i-1]<a[i] && 2*a[i-1] >= a[i] && dp[i-1]+1>dp[i])//判斷后一個數是不是比前一個數大且小于前一個數的2倍,并且最長上升子序列是否還可以增加dp[i] = dp[i-1]+1;else dp[i] = 1;ans = max(ans, dp[i]);//因為最后一個dp不一定是最長上升子序列,所以要讓某個數把最大的結果存起來 }printf("%d\n", ans);return 0; }

?

轉載于:https://www.cnblogs.com/RootVount/p/10478757.html

總結

以上是生活随笔為你收集整理的CodeForces - 1029B.Creating the Contest(最长上升子序列0(n)解法)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产精品99久久久久久大便 | 男女插插视频 | 成人性生交大免费看 | 福利一区二区 | 欧美三级又粗又硬 | 国产极品尤物 | 黄色在线免费网站 | 午夜在线播放 | 香蕉久久一区二区三区 | 日本人妖网站 | 美日韩av在线 | 亚洲午夜精品一区二区 | www.久久视频| 日韩综合另类 | 操女人逼逼视频 | 少妇在军营h文高辣 | 久久精品男人的天堂 | 欧美亚洲 | 日韩精品电影一区二区 | 亚洲日本精品一区 | 午夜精品999 | 精品人妻无码一区二区性色 | 欧美精品人妻一区二区 | 国产成人自拍一区 | 国产第一精品视频 | 国产精品日韩在线观看 | 国产亚洲一区在线 | 大地资源在线观看免费高清版粤语 | 特黄网站| 国产系列在线观看 | 亚洲一区二区图片 | 久久久久成人精品无码 | 久久精品视频5 | 鲁一鲁色一色 | 亚洲av色香蕉一区二区三区 | 98在线视频 | 成人av图片 | av一区二区不卡 | 成人区人妻精品一区 | 中文字幕无码毛片免费看 | 激情小视频在线观看 | 婷婷丁香六月 | 国产美女又黄又爽又色视频免费 | 午夜免费 | 国产自产精品 | 九九热在线精品视频 | av最新版天堂资源在线 | 男人影院在线 | 波多野结衣精品视频 | 国产精品一卡二卡在线观看 | 亚洲天堂区 | 一区二区三区四区在线视频 | 国产性猛交普通话对白 | 国产无遮挡免费视频 | 亚洲黄色小说图片 | 国产精品一品二区三区的使用体验 | 亚洲在线| 亚洲影院在线 | 亚洲美女综合网 | 国产亚洲成人av | 超碰人人擦 | 日本免费一区二区视频 | 操她视频在线观看 | 小妹色播影院 | 最新黄色网址在线观看 | 日本免费黄色 | 免费观看av的网站 | 在线观看成年人网站 | 99精品人妻无码专区在线视频区 | 人妻丰满熟妇av无码久久洗澡 | 永久免费在线视频 | 99在线观看精品视频 | 亚洲色图图片 | 亚洲一二三在线 | 亚洲中文字幕久久无码 | 搞黄视频在线观看 | 欧美中文字幕在线视频 | 亚洲小说区图片区 | 久久久久久人妻一区二区三区 | 欧美一卡| 天天躁狠狠躁狠狠躁夜夜躁68 | caoprom超碰| 少妇无套高潮一二三区 | 欧美一区二区网站 | 日韩国产二区 | 国产xxxx在线观看 | 日本午夜大片 | 可以看av的网站 | 三级做爰在线观看视频 | 日韩人妻无码精品久久久不卡 | 欧美第一页草草影院 | 亚洲精品免费在线视频 | 性生活网址| 久久综合丁香 | 老湿影院av | 猎艳山村丰满少妇 | 亚洲精品久久久中文字幕痴女 | 双性娇喘浑圆奶水h男男漫画 | 亚洲精品乱码久久久久久国产主播 |