当前位置:网站首页>【无标题】LeetCode 2321. 拼接数组的最大分数
【无标题】LeetCode 2321. 拼接数组的最大分数
2022-07-02 11:26:00 【HumbleFool】
LeetCode 2321. 拼接数组的最大分数
前缀和、区间最大值
class Solution {
public:
int process(vector<int>& a, vector<int>& b)
{
int sum = 0;
for(auto& n : a) sum += n;
int dt = 0, t = 0;
for(int i = 0; i < a.size(); i ++)
{
t = max(t + b[i] - a[i], b[i] - a[i]);
dt = max(dt, t);
}
return sum + dt;
}
int maximumsSplicedArray(vector<int>& nums1, vector<int>& nums2) {
return max(process(nums1, nums2), process(nums2, nums1));
}
};
边栏推荐
- 实现一个多进程并发的服务器
- 篇9:XShell免费版安装
- STM32 standard firmware library function name memory (II)
- 4. Array pointer and pointer array
- Wechat applet uses towxml to display formula
- Database connection pool and data source
- ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
- A white hole formed by antineutrons produced by particle accelerators
- 4、数组指针和指针数组
- 微信小程序使用towxml显示公式
猜你喜欢

Add vector formula in rich text editor (MathType for TinyMCE, visual addition)

途家木鸟美团夏日折扣对垒,门槛低就一定香吗?

What is erdma? Popular science cartoon illustration

Stm32-dac Experiment & high frequency DAC output test

buuctf-pwn write-ups (7)

由粒子加速器产生的反中子形成的白洞

Tujia muniao meituan has a discount match in summer. Will it be fragrant if the threshold is low?

Yolov6 training: various problems encountered in training your dataset

Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute

Reuse and distribution
随机推荐
PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
求轮廓最大内接圆
Fabric. JS manual bold text iText
HMS core machine learning service helps zaful users to shop conveniently
What is erdma? Popular science cartoon illustration
Bit by bit of OpenCV calling USB camera
Reuse and distribution
Makefile 分隔文件名与后缀
Yolov6 training: various problems encountered in training your dataset
NLA自然语言分析实现数据分析零门槛
MathML to latex
Tencent cloud tstor unified storage passed the evaluation of the first batch of basic file storage capabilities of the ICT Institute
[Space & single cellomics] phase 1: single cell binding space transcriptome research PDAC tumor microenvironment
实现一个多进程并发的服务器
OpenCV调用USB摄像头的点滴
A white hole formed by antineutrons produced by particle accelerators
Fabric. JS free drawing ellipse
C语言高级用法--函数指针:回调函数;转换表
电脑怎么设置扬声器播放麦克风的声音
MQ tutorial | exchange (switch)