📢📢📢传送门
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) (m−s), 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 1≤t≤103) — 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 1≤n≤100).
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 1≤ai≤100).
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 1≤bi≤100).
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]