当前位置:网站首页>[untitled] leetcode 2321 Maximum score of concatenated array
[untitled] leetcode 2321 Maximum score of concatenated array
2022-07-02 14:53:00 【HumbleFool】
LeetCode 2321. The maximum score of a concatenated array
The prefix and 、 Interval maximum
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));
}
};
边栏推荐
- buuctf-pwn write-ups (7)
- PHP linked list creation and traversal
- Wechat applet uses towxml to display formula
- taobao. trade. Get (get some information of a single transaction), Taobao store order interface, Taobao oauth2.0 interface, Taobao R2 interface code docking and sharing
- C# richTextBox控制显示最大行数
- Quick analysis: easy to share the Internet
- Find the maximum inscribed circle of the contour
- Check password
- taobao.trade.memo.add( 对一笔交易添加备注 )接口,淘宝店铺插旗接口,淘宝订单插旗API接口,oAuth2.0接口
- mathjax 入门(web显示数学公式,矢量的)
猜你喜欢
Advanced C language (learn malloc & calloc & realloc & free in simple dynamic memory management)
Development and design of animation surrounding mall sales website based on php+mysql
kityformula-editor 配置字号和间距
Ad20 cannot select the solution of component packaging in PCB editor
Socket and socket address
Full of knowledge points, how to use JMeter to generate encrypted data and write it to the database? Don't collect it quickly
Advanced C language (realize simple address book)
报错:npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead.
mathML转latex
btrace-(字节码)动态跟踪工具
随机推荐
MFC 控制台打印,弹出对话框
taobao. trade. memo. Add (add remarks to a transaction) interface, Taobao store flag insertion interface, Taobao order flag insertion API interface, oauth2.0 interface
1. Editing weapon VIM
< schematic diagram of oral arithmetic exercise machine program development> oral arithmetic exercise machine / oral arithmetic treasure / children's math treasure / children's calculator LCD LCD driv
ONNX+TensorRT:将预处理操作写入ONNX并完成TRT部署
Fabric. JS dynamically set font size
##51单片机实验之简易验证码发生器
广州市应急管理局发布7月高温高湿化工安全提醒
Li Chuang EDA learning notes 15: draw border or import border (DXF file)
Add vector formula in rich text editor (MathType for TinyMCE, visual addition)
4. Array pointer and pointer array
测试框架TestNG的使用(二):testNG xml的使用
Find the maximum inscribed circle of the contour
Xilinx Vivado set *.svh as SystemVerilog Header
电脑怎么设置扬声器播放麦克风的声音
Fabric. JS free drawing ellipse
3. Function pointers and pointer functions
STM32 library function for GPIO initialization
CTO如何帮助业务?
Fabric.js 动态设置字号大小