当前位置: 首页 > news >正文

餐饮 公司 网站建设友情链接出售平台

餐饮 公司 网站建设,友情链接出售平台,wordpress页面突然不能访问,汕头澄海玩具厂CF1692G 2^Sort 题解题目链接字面描述题面翻译题目描述输入格式输出格式样例 #1样例输入 #1样例输出 #1提示思路代码实现题目 链接 https://www.luogu.com.cn/problem/CF1692G 字面描述 题面翻译 给你一个长度为 n(∑n<2⋅105)n \ (\sum n < 2\cdot 10^5)n (∑n<…

CF1692G 2^Sort 题解

  • 题目
    • 链接
    • 字面描述
      • 题面翻译
      • 题目描述
      • 输入格式
      • 输出格式
      • 样例 #1
        • 样例输入 #1
      • 样例输出 #1
    • 提示
  • 思路
  • 代码实现

题目

链接

https://www.luogu.com.cn/problem/CF1692G

字面描述

题面翻译

给你一个长度为 n(∑n<2⋅105)n \ (\sum n < 2\cdot 10^5)n (n<2105) 的数组 aaa,问你在这个数组中,有多少个长度为 k+1(1≤k<n)k + 1 \ (1\le k < n)k+1 (1k<n) 的区间,符合以下的条件:

20⋅ai<21⋅ai+1<22⋅ai+2<⁣⋯<2k⋅ai+k注:i为这个区间开始的位置2^0 \cdot a_i < 2^1 \cdot a_{i + 1} < 2^2 \cdot a_{i + 2} < \dotsi < 2^k \cdot a_{i + k}\\ \footnotesize{注:i 为这个区间开始的位置} 20ai<21ai+1<22ai+2<<2kai+k注:i为这个区间开始的位置

由tzyt翻译

题目描述

Given an array $ a $ of length $ n $ and an integer $ k $ , find the number of indices $ 1 \leq i \leq n - k $ such that the subarray $ [a_i, \dots, a_{i+k}] $ with length $ k+1 $ (not with length $ k $ ) has the following property:

  • If you multiply the first element by $ 2^0 $ , the second element by $ 2^1 $ , …, and the ( $ k+1 $ )-st element by $ 2^k $ , then this subarray is sorted in strictly increasing order.

More formally, count the number of indices $ 1 \leq i \leq n - k $ such that $ $KaTeX parse error: Can't use function '$' in math mode at position 84: …\cdot a_{i+k}. $̲ $

输入格式

The first line contains an integer $ t $ ( $ 1 \leq t \leq 1000 $ ) — the number of test cases.

The first line of each test case contains two integers $ n $ , $ k $ ( $ 3 \leq n \leq 2 \cdot 10^5 $ , $ 1 \leq k < n $ ) — the length of the array and the number of inequalities.

The second line of each test case contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 1 \leq a_i \leq 10^9 $ ) — the elements of the array.

The sum of $ n $ across all test cases does not exceed $ 2 \cdot 10^5 $ .

输出格式

For each test case, output a single integer — the number of indices satisfying the condition in the statement.

样例 #1

样例输入 #1

6
4 2
20 22 19 84
5 1
9 5 3 2 1
5 2
9 5 3 2 1
7 2
22 12 16 4 3 22 12
7 3
22 12 16 4 3 22 12
9 3
3 9 12 3 9 12 3 9 12

样例输出 #1

2
3
2
3
1
0

提示

In the first test case, both subarrays satisfy the condition:

  • $ i=1 $ : the subarray $ [a_1,a_2,a_3] = [20,22,19] $ , and $ 1 \cdot 20 < 2 \cdot 22 < 4 \cdot 19 $ .
  • $ i=2 $ : the subarray $ [a_2,a_3,a_4] = [22,19,84] $ , and $ 1 \cdot 22 < 2 \cdot 19 < 4 \cdot 84 $ .

In the second test case, three subarrays satisfy the condition: - $ i=1 $ : the subarray $ [a_1,a_2] = [9,5] $ , and $ 1 \cdot 9 < 2 \cdot 5 $ .

  • $ i=2 $ : the subarray $ [a_2,a_3] = [5,3] $ , and $ 1 \cdot 5 < 2 \cdot 3 $ .
  • $ i=3 $ : the subarray $ [a_3,a_4] = [3,2] $ , and $ 1 \cdot 3 < 2 \cdot 2 $ .
  • $ i=4 $ : the subarray $ [a_4,a_5] = [2,1] $ , but $ 1 \cdot 2 = 2 \cdot 1 $ , so this subarray doesn’t satisfy the condition.

思路

对原数组进行模拟下标x(2n)x(2~n)x(2 n)
根据题目
ax−1<2⋅axa_{x-1}<2\cdot a_xax1<2ax
∴fx=1\therefore f_x=1fx=1
否则,fx=0f_x=0fx=0

f数组f数组f数组进行前缀和预处理,就可以实现O(n)\Omicron(n)O(n)时间复杂度的统计了。

代码实现

#include<bits/stdc++.h>
using namespace std;const int maxn=2e5+10;
int t,n,k,ans;
int a[maxn],f[maxn];
int main(){scanf("%d",&t);while(t--){scanf("%d%d",&n,&k);int op=0;ans=0;memset(a,0,sizeof(a));for(int i=1;i<=n;i++){int x;scanf("%d",&x);if(2*x>op)a[i]=1;op=x;}for(int i=1;i<=n;i++){f[i]=f[i-1]+a[i];if(i-k-1<0)continue;if(f[i]-f[i-k]==k)++ans;}printf("%d\n",ans);}return 0;
} 
http://www.hengruixuexiao.com/news/33442.html

相关文章:

  • 外贸网站宗旨朝阳网站建设
  • 全国商城网站建设福州网站建设方案外包
  • 网站是否有管理员权限百度知道客服电话人工服务
  • 百度搜到自己网站国产免费crm系统有哪些在线
  • 商城 网站 功能酒店网络营销方式有哪些
  • wordpress环境配置文件全达seo
  • 足球做网站首页格局广告免费推广网
  • 无锡网站建设营销型seo搜索引擎优化关键词
  • 自己做的网站怎么上线全渠道营销成功案例
  • 重庆专业做网站关键词排名点击器
  • 哈尔滨做网站公司有哪些巨量关键词搜索查询
  • 帮忙做宴会的网站seo关键词排名如何
  • 汽车最好网站建设如何分析百度指数
  • 做网站流程线上推广有哪些
  • 外贸seo建站seo软文是什么
  • 网站页脚的信息都有什么百度快照是干嘛的
  • 谁在万网建设的网站bt兔子磁力搜索
  • 360竞价推广怎么做湖南企业seo优化报价
  • 建设网证书查询在线优化seo
  • 普通网站建设费用北京环球影城每日客流怎么看
  • 北京公司注册核名网站百度集团公司简介
  • 广州建网站比较有名的公司快速排名优化公司
  • 网站建设 51下拉平台台州网站建设
  • 商城建设网站的原因公司网站如何在百度上能搜索到
  • 深圳做网站建设的哪家效果好又便宜爱站网收录
  • 如何做团购网站中的美食地处地图功能培训网站推荐
  • 网站 收录 做301seo推广价格
  • 软件开发网站建设科技有限公司网络运营培训班多少钱
  • 网页设计与网站建设案例教程网络营销常用的工具和方法
  • 网站开发部门的规章制度国内优秀网页设计赏析