当前位置:网站首页>[cf] 803 div2 B. Rising Sand
[cf] 803 div2 B. Rising Sand
2022-06-30 12:07:00 【*DDL_ GzmBlog】
Preface
t a g : tag : tag: thinking Interval modification Fixed answer
Portal :
The question
Given an array A A A, about A [ i ] > A [ i − 1 ] + A [ i + 1 ] A[i]>A[i-1]+A[i+1] A[i]>A[i−1]+A[i+1], We define it as Too high , At the same time, give a k k k, You can make the interval length k k k Of A [ i ] + 1 A[i]+1 A[i]+1, inquiry After any operation You can get the maximum number of heaps that are too high
Ideas
Because the answer is calculated as A [ i ] > A [ i − 1 ] + A [ i + 1 ] A[i]>A[i-1]+A[i+1] A[i]>A[i−1]+A[i+1]
So we found that k ≥ 2 k\ge2 k≥2 When , Very difficult to change or add answers
Look at the :
- If the entire triple is increased , a i + 1 > a i + 1 + a i − 1 + 2 a_i+1>a_{i+1}+a_{i-1}+2 ai+1>ai+1+ai−1+2
- In case of partial increase , a i + 1 > a i − 1 + a i + 1 + 1 a_i+1 > a_{i-1}+a_{i+1}+1 ai+1>ai−1+ai+1+1
So we can see that No operation is the best
And for k = = 1 k==1 k==1 The situation of
We can know that because it is an arbitrary operation , So at most n − 2 2 \frac{n-2}{2} 2n−2, Do not calculate endpoints
Mycode
int n,k;
int a[N];
void solve(){
cin>>n>>k;
for(int i=1;i<=n;i++) cin>>a[i];
int cnt = 0 ;
if(k!=1){
for(int i= 2 ; i <n ; i ++ )
if(a[i] > a[i-1] + a[i+1]) cnt++;
}else{
if(n&1) cnt = (n-2)/2 + 1;
else cnt = (n-2)/2;
}
cout<<cnt<<endl;
}
int main(){
int t;cin>>t;while(t--)
solve();
return 0 ;
}
边栏推荐
- 【模式识别大作业】
- nvm安装node后,在使用npm指令时候显示不是内部或外部指令
- R language ggplot2 visualization: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)
- R language ggplot2 visualization: use ggplot2 to visualize the scatter diagram and use scale_ x_ The log10 function configures the value range of the X axis to be logarithmic coordinates
- DMA控制器8237A
- Speech signal processing - Fundamentals (V): Fourier transform
- wallys/600VX – 2×2 MIMO 802.11ac Mini PCIe Wi-Fi Module, Dual Band, 2,4GHz / 5GHz QCA 9880
- 用宝塔建第2个网站时网站总是报错:No input file specified.
- R语言ggplot2可视化:gganimate包基于transition_time函数创建动态散点图动画(gif)、使用labs函数为动画图添加动态时间标题(抽取frame_time信息)
- goto语句跳转未初始化变量:C2362
猜你喜欢

Let's talk about how to do hardware compatibility testing and quickly migrate to openeuler?

1175. prime permutation

How can c write an SQL parser

【LeetCode】15、三数之和

基于视觉的机器人抓取:从物体定位、物体姿态估计到平行抓取器抓取估计

Conference Preview - Huawei 2012 lab global software technology summit - European session

Beego development blog system learning (II)
![[pattern recognition]](/img/b1/dcb444cbf40a43eeb7f7b233d7741a.png)
[pattern recognition]

nvm安装node后,在使用npm指令时候显示不是内部或外部指令

The sci-fi ideas in these movies have been realized by AI
随机推荐
Conference Preview - Huawei 2012 lab global software technology summit - European session
shell第一个命令结果传入第二个命令删除
Our company has used this set of general solutions for 7 years, and has opened up dozens of systems, a stable batch!
zabbix监控TCP连接个数
A High-Precision Positioning Approach for Catenary Support Components With Multiscale Difference阅读笔记
来聊聊怎么做硬件兼容性检测,快速迁移到openEuler?
【模式识别大作业】
STM32 porting the fish component of RT thread Standard Edition
time 函数和 clock_gettime()函数的区别
redis在项目中的使用
Another miserable day by kotlin grammar
[revisiting the classic C language] ~x,%c,%d,%x, etc. in C language, the role of the address character in C language, and the consortium in C language
Shutter start from zero 006 radio switches and checkboxes
MySQL 表的内连和外连
Flutter 从零开始 005 图片及Icon
R语言ggplot2可视化:使用ggplot2可视化散点图、使用scale_color_viridis_d函数指定数据点的配色方案
1175. 质数排列 : 乘法原理运用题
Boost study: boost log
R language ggplot2 visual Facet: gganimate package is based on Transition_ The time function creates a dynamic scatter graph animation (GIF) and uses the labs function to add a dynamic time title to t
8253计数器介绍