Codeforces Round 995 (Div. 3)

在这里插入图片描述

A. Preparing for the Olympiad

Monocarp and Stereocarp are preparing for the Olympiad. There are n n n days left until the Olympiad. On the i i i-th day, if Monocarp plans to practice, he will solve a i a_i ai problems. Similarly, if Stereocarp plans to practice on the same day, he will solve b i b_i bi problems.

Monocarp can train on any day he wants. However, Stereocarp watches Monocarp and follows a different schedule: if Monocarp trained on day i i i and KaTeX parse error: Expected 'EOF', got '&' at position 3: i &̲lt; n, then Stereocarp will train on day ( i + 1 ) (i+1) (i+1).

Monocarp wants to organize his training process in a way that the difference between the number of problems he solves and the number of problems Stereocarp solves is as large as possible. Formally, Monocarp wants to maximize the value of ( m − s ) (m-s) (ms), where m m m is the number of problems he solves, and s s s is the number of problems Stereocarp solves. Help Monocarp determine the maximum possible difference in the number of solved problems between them.

Input

The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 3 1 \le t \le 10^3 1t103) — the number of test cases.

The first line of each test case contains a single integer n n n ( 1 ≤ n ≤ 100 1 \le n \le 100 1n100).

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \dots, a_n a1,a2,,an ( 1 ≤ a i ≤ 100 1 \le a_i \le 100 1ai100).

The third line contains n n n integers b 1 , b 2 , … , b n b_1, b_2, \dots, b_n b1,b2,,bn ( 1 ≤ b i ≤ 100 1 \le b_i \le 100 1bi100).

Output

For each test case, print a single integer — the maximum possible difference between the number of problems Monocarp solves and the number of problems Stereocarp solves.

解题思路及AC代码

签到题

#include<bits/stdc++.h>
#define int long long
using namespace std;
using i64 = long long;
const int N = 2e5 + 10;
void solve(){
   
	int n;
	cin >> n;
	vector<int> a(n),b(n);
	for(int i = 0;i < n;i ++){
   
		cin >> a[i];
	}
	for(int i = 0;i < n;i ++){
   
		cin >> b[i]
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈童学哦

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值