当前位置:网站首页>【无标题】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));
}
};
边栏推荐
- 一张图彻底掌握prototype、__proto__、constructor之前的关系(JS原型、原型链)
- 3、函数指针和指针函数
- STM32 standard firmware library function name (I)
- 4. Array pointer and pointer array
- threejs的控制器 立方体空间 基本控制器+惯性控制+飞行控制
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- 报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
- Li Chuang EDA learning notes 15: draw border or import border (DXF file)
- 删除元素(带过渡动画)
- jmeter脚本参数化
猜你喜欢
Thoroughly master prototype__ proto__、 Relationship before constructor (JS prototype, prototype chain)
STM32 library function for GPIO initialization
Tip: SQL Server blocked the state 'openrowset/opendatasource' of component 'ad hoc distributed queries'
Daily learning 3
Makefile separates file names and suffixes
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
Fabric. Usage of JS eraser (including recovery function)
taobao.trade.memo.add( 对一笔交易添加备注 )接口,淘宝店铺插旗接口,淘宝订单插旗API接口,oAuth2.0接口
跨服务器数据访问的创建链接服务器方法
Yolov6 training: various problems encountered in training your dataset
随机推荐
Fabric. JS free drawing ellipse
kityformula-editor 配置字号和间距
ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
求轮廓最大内接圆
Basic knowledge of QT original code
3、函数指针和指针函数
Threejs controller cube space basic controller + inertia control + flight control
Error: NPM warn config global ` --global`, `--local` are deprecated Use `--location=global` instead.
[QNX Hypervisor 2.2用户手册]6.3 Guest与外部之间通信
Database connection pool and data source
PTA题库 ===>复数四则运算,一帮一,考试座位号(7-73)
没有从远程服务器‘‘映射到本地用户‘(null)/sa‘的远程用户‘sa‘及服务主密码解密错误的解决办法
Yolov3 & yolov5 output result description
卷积神经网络(入门)
QT new project
Simple verification code generator for 51 single chip microcomputer experiment
Generally speaking, if the error of inconsistent tab and space occurs frequently
taobao.trade.get( 获取单笔交易的部分信息),淘宝店铺订单接口,淘宝oAuth2.0接口,淘宝R2接口代码对接分享
fatal: unsafe repository is owned by someone else 的解决方法
A white hole formed by antineutrons produced by particle accelerators