当前位置:网站首页>[HDU] 5248 sequence transformation (greedy + dichotomy) [recommended collection]
[HDU] 5248 sequence transformation (greedy + dichotomy) [recommended collection]
2022-07-07 19:09:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm the king of the whole stack .
The length of binary enumeration can be changed
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF = 3000000;
const int maxn = 100005;
int n,arr[maxn],arr2[maxn];
bool solve(int x){
memcpy(arr2,arr,sizeof(arr));
for(int i = 1; i <= n; i++){
if(arr2[i] > arr2[i - 1]){
arr2[i] = max(arr2[i - 1] + 1,arr2[i] - x);
}
else{
if(arr2[i] + x <= arr2[i - 1]) return false;
arr2[i] = arr2[i - 1] + 1;
}
}
return true;
}
int main(){
int T,Case = 1;
scanf("%d",&T);
arr[0] = -INF;
while(T--){
scanf("%d",&n);
for(int i = 1; i <= n; i++)
scanf("%d",&arr[i]);
int l = 0,r = INF;
int ans = n;
while(l <= r){
int mid = (l + r) >> 1;
if(solve(mid)){
ans = mid;
r = mid - 1;
}
else
l = mid + 1;
}
printf("Case #%d:\n",Case++);
printf("%d\n",ans);
}
return 0;
}Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/116609.html Link to the original text :https://javaforall.cn
边栏推荐
- 行业案例|数字化经营底座助力寿险行业转型
- The highest level of anonymity in C language
- 基于图像和激光的多模态点云融合与视觉定位
- 博睿数据入选《2022爱分析 · IT运维厂商全景报告》
- Antisamy: a solution against XSS attack tutorial
- [C language] string function
- Cloud security daily 220707: Cisco Expressway series and telepresence video communication server have found remote attack vulnerabilities and need to be upgraded as soon as possible
- 我感觉被骗了,微信内测 “大小号” 功能,同一手机号可注册两个微信
- The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t
- 2022-07-04 matlab读取视频帧并保存
猜你喜欢
![[tpm2.0 principle and Application guide] Chapter 9, 10 and 11](/img/7f/0d4d91142bc3d79ea445a8f64afba7.png)
[tpm2.0 principle and Application guide] Chapter 9, 10 and 11

The performance and efficiency of the model that can do three segmentation tasks at the same time is better than maskformer! Meta & UIUC proposes a general segmentation model with better performance t

3.关于cookie

博睿数据入选《2022爱分析 · IT运维厂商全景报告》

Calculation of torque target value (ftorque) in servo torque control mode

【Unity Shader】插入Pass实现模型遮挡X光透视效果

SlashData开发者工具榜首等你而定!!!

链式二叉树的基本操作(C语言实现)

Charles+Postern的APP抓包

RIP和OSPF的区别和配置命令
随机推荐
Draw squares with Obama (Lua)
[unity shader] insert pass to realize the X-ray perspective effect of model occlusion
Cloud security daily 220707: Cisco Expressway series and telepresence video communication server have found remote attack vulnerabilities and need to be upgraded as soon as possible
Creative changes brought about by the yuan universe
咋吃都不胖的朋友,Nature告诉你原因:是基因突变了
脑洞从何而来?加州大学最新研究:有创造力的人神经连接会「抄近道」
Idea completely uninstalls installation and configuration notes
2022上半年朋友圈都在传的10本书,找到了
Comparison and selection of kubernetes Devops CD Tools
2022.07.02
CVPR 2022丨学习用于小样本语义分割的非目标知识
清华、剑桥、UIC联合推出首个中文事实核查数据集:基于证据、涵盖医疗社会等多个领域
【软件测试】从企业版BOSS直聘,看求职简历,你没被面上是有原因的
Datasimba launched wechat applet, and datanuza accepted the test of the whole scene| StartDT Hackathon
Complete e-commerce system
如何选择合适的自动化测试工具?
伺服力矩控制模式下的力矩目标值(fTorque)计算
testing and SQA_动态白盒測试[通俗易懂]
6. About JWT
LeetCode 497(C#)