【洛谷】AT_abc373_c [ABC373C] Max Ai+Bj 的题解

【洛谷】AT_abc373_c [ABC373C] Max Ai+Bj 的题解

洛谷传送门

AT传送门

题解

题目大意:

给定两个长度为 N N N 的序列 A A A B B B,求 A i + B j A_i + B_j Ai+Bj 的最大值。

那这样的话就很简单,只要在输入的时候找到 A A A 数组的最大值和 B B B 数组的最大值,然后分别将 A max ⁡ A_{\max} Amax B max ⁡ B_{\max} Bmax 相加就可以了qaq。

不开 long long 见祖宗

代码

#include <bits/stdc++.h>
#define lowbit(x) x & (-x)
#define endl "\n"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
namespace fastIO {
	inline int read() {
		register int x = 0, f = 1;
		register char c = getchar();
		while (c < '0' || c > '9') {
			if(c == '-') f = -1;
			c = getchar();
		}
		while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
		return x * f;
	}
	inline void write(int x) {
		if(x < 0) putchar('-'), x = -x;
		if(x > 9) write(x / 10);
		putchar(x % 10 + '0');
		return;
	}
}
using namespace fastIO;
ll n; 
ll a, b, maxa = -1e9 - 7, maxb = -1e9 - 7; 
int main() {
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a;
		maxa = max(maxa, a);
	}
	for(int i = 1; i <= n; i ++) {
		cin >> b;
		maxb = max(maxb, b);
	}
	cout << maxa + maxb;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值