Codeforces Hello 2024 (ABCDF1题)

发布时间:2024年01月08日

A. Wallet Exchange

Problem Statement

Alice and Bob are bored, so they decide to play a game with their wallets. Alice has a a a coins in her wallet, while Bob has b b b coins in his wallet.

Both players take turns playing, with Alice making the first move. In each turn, the player will perform the following steps in order:

  1. Choose to exchange wallets with their opponent, or to keep their current wallets.
  2. Remove 1 1 1 coin from the player’s current wallet. The current wallet cannot have 0 0 0 coins before performing this step.

The player who cannot make a valid move on their turn loses. If both Alice and Bob play optimally, determine who will win the game.

Input

Each test contains multiple test cases. The first line contains a single integer t t t ( 1 ≤ t ≤ 1000 1 \leq t \leq 1000 1t1000) — the number of test cases. The description of the test cases follows.

The first and only line of each test case contains two integers a a a and b b b ( 1 ≤ a , b ≤ 1 0 9 1 \le a, b \le 10^9 1a,b109) — the number of coins in Alice’s and Bob’s wallets, respectively.

Output

For each test case, output “Alice” if Alice will win the game, and “Bob” if Bob will win the game.

Example

input
10
1 1
1 4
5 3
4 5
11 9
83 91
1032 9307
839204 7281
1000000000 1000000000
53110 2024
output
Bob
Alice
Bob
Alice
Bob
Bob
Alice
Alice
Bob
Bob

Note

In the first test case, an example of the game is shown below:

  • Alice chooses to not swap wallets with Bob in step 1 of her move. Now, a = 0 a=0 a=0 and b = 1 b=1 b=1.
  • Since Alice’s wallet is empty, Bob must choose to not swap their wallets in step 1 of his move. Now, a = 0 a=0 a=0 and b = 0 b=0 b=0.
  • Since both Alice’s and Bob’s wallets are empty, Alice is unable to make a move. Hence, Bob wins.

In the second test case, an example of the game is shown below:

  • Alice chooses to swap wallets with Bob in step 1 of her move. Now, a = 3 a=3 a=3 and b = 1 b=1 b=1.
  • Bob chooses to swap wallets with Alice in step 1 of his move. Now, a = 1 a=1 a=1 and b = 2 b=2 b=2.
  • Alice chooses to not swap wallets with Bob in step 1 of her move. Now, a = 0 a=0 a=0 and b = 2 b=2 b=2.
  • Since Alice’s wallet is empty, Bob can only choose to not swap wallets with Alice in step 1 of his move. Now, a = 0 a=0 a=0 and b = 1 b=1 b=1.
  • Since Alice’s wallet is empty, Alice can only choose to swap wallets with Bob in step 1 of her move. Now, a = 0 a=0 a=0 and b = 0 b=0 b=0.
  • Since both Alice’s wallet and Bob’s wallet are empty, Bob is unable to make a move. Hence, Alice wins.

Solution

具体见文后视频。


Code

#include <bits/stdc++.h>
#define int long long

using namespace std;

typedef pair<int, int> PII;

void solve()
{
	int A, B;

	cin >> A >> B;

	if (abs(A - B) & 1) cout << "Alice" << endl;
	else cout << "Bob" << endl;
}

signed main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);

	int Data;

	cin >> Data;

	while (Data --)
		solve();

	return 0;
}

B. Plus-Minus Split

Problem Statement

You are given a string s s s of length n n n consisting of characters “+” and “-”. s s s represents an array a a a of length n n n defined by a i = 1 a_i=1 ai?=1 if s i = s_i= si?= “+” and a i = ? 1 a_i=-1 ai?=?1 if s i = s_i= si?= “-”.

You will do the following process to calculate your penalty:

  1. Split a a a into non-empty arrays b 1 , b 2 , … , b k b_1,b_2,\ldots,b_k b1?,b2?,,bk? such that b 1 + b 2 + … + b k = a ? b_1+b_2+\ldots+b_k=a^\dagger b1?+b2?++bk?=a?, where + + + denotes array concatenation.
  2. The penalty of a single array is the absolute value of its sum multiplied by its length. In other words, for some array c c c of length m m m, its penalty is calculated as p ( c ) = ∣ c 1 + c 2 + … + c m ∣ ? m p(c)=|c_1+c_2+\ldots+c_m| \cdot m p(c)=c1?+c2?++cm??m.
  3. The total penalty that you will receive is p ( b 1 ) + p ( b 2 ) + … + p ( b k ) p(b_1)+p(b_2)+\ldots+p(b_k) p(b1?)+p(b2?)++p(bk?).

If you perform the above process optimally, find the minimum possible penalty you will receive.

? ^\dagger ? Some valid ways to split a = [ 3 , 1 , 4 , 1 , 5 ] a=[3,1,4,1,5] a=[3,1,4,1,5] into ( b 1 , b 2 , … , b k ) (b_1,b_2,\ldots,b_k) (b1?,b2?,,bk?) are ( [ 3 ] , [ 1 ] , [ 4 ] , [ 1 ] , [ 5 ] ) ([3],[1],[4],[1],[5]) ([3],[1],[4],[1],[5]), ( [ 3 , 1 ] , [ 4 , 1 , 5 ] ) ([3,1],[4,1,5]) ([3,1],[4,1,5]) and ( [ 3 , 1 , 4 , 1 , 5 ] ) ([3,1,4,1,5]) ([3,1,4,1,5]) while some invalid ways to split a a a are ( [ 3 , 1 ] , [ 1 , 5 ] ) ([3,1],[1,5]) ([3,1],[1,5]), ( [ 3 ] , [ ? ] , [ 1 , 4 ] , [ 1 , 5 ] ) ([3],[\,],[1,4],[1,5]) ([3],[],[1,4],[1,5]) and ( [ 3 , 4 ] , [ 5 , 1 , 1 ] ) ([3,4],[5,1,1]) ([3,4],[5,1,1]).

Input

Each test contains multiple test cases. The first line contains a single integer t t t ( 1 ≤ t ≤ 1000 1 \leq t \leq 1000 1t1000) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n n n ( 1 ≤ n ≤ 5000 1 \le n \le 5000 1n5000) — the length of string s s s.

The second line of each test case contains string s s s ( s i ∈ { + , ? } s_i \in \{ \mathtt{+}, \mathtt{-} \} si?{+,?}, ∣ s ∣ = n |s| = n s=n).

Note that there are no constraints on the sum of n n n over all test cases.

Output

For each test case, output a single integer representing the minimum possible penalty you will receive.

Example

input
5
1
+
5
-----
6
+-+-+-
10
--+++++++-
20
+---++++-+++++---++-
output
1
5
0
4
4

Solution

具体见文后视频。


Code

#include <bits/stdc++.h>
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 5e3 + 10;

int N;
string S;

void solve()
{
	cin >> N >> S;

	S = ' ' + S;
	int Result = 0;
	for (int i = 1; i <= N; i ++)
		if (S[i] == '+')
			Result ++;
		else
			Result --;

	cout << abs(Result) << endl;
}

signed main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);

	int Data;

	cin >> Data;

	while (Data --)
		solve();

	return 0;
}

C. Grouping Increases

Problem Statement

You are given an array a a a of size n n n. You will do the following process to calculate your penalty:

  1. Split array a a a into two (possibly empty) subsequences ? ^\dagger ? s s s and t t t such that every element of a a a is either in s s s or t ? t^\ddagger t?.
  2. For an array b b b of size m m m, define the penalty p ( b ) p(b) p(b) of an array b b b as the number of indices i i i between 1 1 1 and m ? 1 m - 1 m?1 where b i < b i + 1 b_i < b_{i + 1} bi?<bi+1?.
  3. The total penalty you will receive is p ( s ) + p ( t ) p(s) + p(t) p(s)+p(t).

If you perform the above process optimally, find the minimum possible penalty you will receive.

? ^\dagger ? A sequence x x x is a subsequence of a sequence y y y if x x x can be obtained from y y y by the deletion of several (possibly, zero or all) elements.

? ^\ddagger ? Some valid ways to split array a = [ 3 , 1 , 4 , 1 , 5 ] a=[3,1,4,1,5] a=[3,1,4,1,5] into ( s , t ) (s,t) (s,t) are ( [ 3 , 4 , 1 , 5 ] , [ 1 ] ) ([3,4,1,5],[1]) ([3,4,1,5],[1]), ( [ 1 , 1 ] , [ 3 , 4 , 5 ] ) ([1,1],[3,4,5]) ([1,1],[3,4,5]) and ( [ ? ] , [ 3 , 1 , 4 , 1 , 5 ] ) ([\,],[3,1,4,1,5]) ([],[3,1,4,1,5]) while some invalid ways to split a a a are ( [ 3 , 4 , 5 ] , [ 1 ] ) ([3,4,5],[1]) ([3,4,5],[1]), ( [ 3 , 1 , 4 , 1 ] , [ 1 , 5 ] ) ([3,1,4,1],[1,5]) ([3,1,4,1],[1,5]) and ( [ 1 , 3 , 4 ] , [ 5 , 1 ] ) ([1,3,4],[5,1]) ([1,3,4],[5,1]).

Input

Each test contains multiple test cases. The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 4 1 \leq t \leq 10^4 1t104) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n n n ( 1 ≤ n ≤ 2 ? 1 0 5 1\le n\le 2\cdot 10^5 1n2?105) — the size of the array a a a.

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1?,a2?,,an? ( 1 ≤ a i ≤ n 1 \le a_i \le n 1ai?n) — the elements of the array a a a.

It is guaranteed that the sum of n n n over all test cases does not exceed 2 ? 1 0 5 2\cdot 10^5 2?105.

Output

For each test case, output a single integer representing the minimum possible penalty you will receive.

Example

input
5
1
+
5
-----
6
+-+-+-
10
--+++++++-
20
+---++++-+++++---++-
output
3
1
0
0
0

Note

In the first test case, a possible way to split a a a is s = [ 2 , 4 , 5 ] s=[2,4,5] s=[2,4,5] and t = [ 1 , 3 ] t=[1,3] t=[1,3]. The penalty is p ( s ) + p ( t ) = 2 + 1 = 3 p(s)+p(t)=2 + 1 =3 p(s)+p(t)=2+1=3.

In the second test case, a possible way to split a a a is s = [ 8 , 3 , 1 ] s=[8,3,1] s=[8,3,1] and t = [ 2 , 1 , 7 , 4 , 3 ] t=[2,1,7,4,3] t=[2,1,7,4,3]. The penalty is p ( s ) + p ( t ) = 0 + 1 = 1 p(s)+p(t)=0 + 1 =1 p(s)+p(t)=0+1=1.

In the third test case, a possible way to split a a a is s = [ ? ] s=[\,] s=[] and t = [ 3 , 3 , 3 , 3 , 3 ] t=[3,3,3,3,3] t=[3,3,3,3,3]. The penalty is p ( s ) + p ( t ) = 0 + 0 = 0 p(s)+p(t)=0 + 0 =0 p(s)+p(t)=0+0=0.

Solution

具体见文后视频。


Code

#include <bits/stdc++.h>
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 2e5 + 10;

int N;
int A[SIZE];

void solve()
{
    cin >> N;

    for (int i = 1; i <= N; i ++)
        cin >> A[i];

    std::vector<int> S1, S2;
    S1.push_back(1e18), S2.push_back(1e18);

    for (int i = 1; i <= N; i ++)
        if (A[i] > S1.back() && A[i] > S2.back())
        {
            if (S1.back() < S2.back()) S1.push_back(A[i]);
            else S2.push_back(A[i]);
        }
        else if (A[i] > S1.back() && A[i] <= S2.back())
            S2.push_back(A[i]);
        else if (A[i] <= S1.back() && A[i] > S2.back())
            S1.push_back(A[i]);
        else
        {
            if (S1.back() < S2.back()) S1.push_back(A[i]);
            else S2.push_back(A[i]);
        }

    int Result = 0;
    for (int i = 1; i < (int)S1.size(); i ++)
        Result += (S1[i] > S1[i - 1]);
    for (int i = 1; i < (int)S2.size(); i ++)
        Result += (S2[i] > S2[i - 1]);

    cout << Result << endl;
}

signed main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int Data;

    cin >> Data;

    while (Data --)
        solve();

    return 0;
}

D. 01 Tree

Problem Statement

There is an edge-weighted complete binary tree with n n n leaves. A complete binary tree is defined as a tree where every non-leaf vertex has exactly 2 children. For each non-leaf vertex, we label one of its children as the left child and the other as the right child.

The binary tree has a very strange property. For every non-leaf vertex, one of the edges to its children has weight 0 0 0 while the other edge has weight 1 1 1. Note that the edge with weight 0 0 0 can be connected to either its left or right child.

You forgot what the tree looks like, but luckily, you still remember some information about the leaves in the form of an array a a a of size n n n. For each i i i from 1 1 1 to n n n, a i a_i ai? represents the distance ? ^\dagger ? from the root to the i i i-th leaf in dfs order ? ^\ddagger ?. Determine whether there exists a complete binary tree which satisfies array a a a. Note that you do not need to reconstruct the tree.

? ^\dagger ? The distance from vertex u u u to vertex v v v is defined as the sum of weights of the edges on the path from vertex u u u to vertex v v v.

? ^\ddagger ? The dfs order of the leaves is found by calling the following dfs \texttt{dfs} dfs function on the root of the binary tree.

dfs_order = []

function dfs(v):
if v is leaf:
append v to the back of dfs_order
else:
dfs(left child of v)
dfs(right child of v)

dfs(root)

Input

Each test contains multiple test cases. The first line contains a single integer t t t ( 1 ≤ t ≤ 1 0 4 1 \leq t \leq 10^4 1t104) — the number of test cases. The description of the test cases follows.

The first line of each test case contains a single integer n n n ( 2 ≤ n ≤ 2 ? 1 0 5 2 \le n \le 2\cdot 10^5 2n2?105) — the size of array a a a.

The second line of each test case contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1?,a2?,,an? ( 0 ≤ a i ≤ n ? 1 0 \le a_i \le n - 1 0ai?n?1) — the distance from the root to the i i i-th leaf.

It is guaranteed that the sum of n n n over all test cases does not exceed 2 ? 1 0 5 2\cdot 10^5 2?105.

Output

For each test case, print “YES” if there exists a complete binary tree which satisfies array a a a and “NO” otherwise.

You may print each letter in any case (for example, “YES”, “Yes”, “yes”, “yEs” will all be recognized as a positive answer).

Example

input
2
5
2 1 0 1 1
5
1 0 2 1 3
output
YES
NO

Note

In the first test case, the following tree satisfies the array.

In the second test case, it can be proven that there is no complete binary tree that satisfies the array.

Solution

具体见文后视频。


Code

#include <bits/stdc++.h>
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 2e5 + 10;

int N;
int A[SIZE], Next[SIZE], Prev[SIZE];
int Vis[SIZE];

bool Del(int X)
{
	if (X < 1 || X > N) return 0;
	return A[Prev[X]] + 1 == A[X] || A[Next[X]] + 1 == A[X];
}

void solve()
{
	cin >> N;

	for (int i = 1; i <= N; i ++)
		cin >> A[i];

	priority_queue<PII> Heap;
	for (int i = 1; i <= N; i ++)
		Next[i] = i + 1, Prev[i] = i - 1, Vis[i] = 0;

	A[0] = -1e18, A[N + 1] = -1e18;
	for (int i = 1; i <= N; i ++)
		if (Del(i))
			Heap.push({A[i], i}), Vis[i] = 1;

	while (Heap.size())
	{
		auto T = Heap.top();
		Heap.pop();

		int u = T.second;
		Next[Prev[u]] = Next[u], Prev[Next[u]] = Prev[u];
		if (!Vis[Next[u]] && Del(Next[u]))
			Vis[Next[u]] = 1, Heap.push({A[Next[u]], Next[u]});
		if (!Vis[Prev[u]] && Del(Prev[u]))
			Vis[Prev[u]] = 1, Heap.push({A[Prev[u]], Prev[u]});
	}

	int Cnt = 0, Min = 1e18;
	for (int i = 1; i <= N; i ++)
		Cnt += !Vis[i], Min = min(Min, A[i]);

	if (Cnt == 1 && Min == 0) puts("YES");
	else puts("NO");
}

signed main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);

	int Data;

	cin >> Data;

	while (Data --)
		solve();

	return 0;
}

F1. Wine Factory (Easy Version)

Problem Statement

This is the easy version of the problem. The only difference between the two versions is the constraint on c i c_i ci? and z z z. You can make hacks only if both versions of the problem are solved.

There are three arrays a a a, b b b and c c c. a a a and b b b have length n n n and c c c has length n ? 1 n-1 n?1. Let W ( a , b , c ) W(a,b,c) W(a,b,c) denote the liters of wine created from the following process.

Create n n n water towers. The i i i-th water tower initially has a i a_i ai? liters of water and has a wizard with power b i b_i bi? in front of it. Furthermore, for each 1 ≤ i ≤ n ? 1 1 \le i \le n - 1 1in?1, there is a valve connecting water tower i i i to i + 1 i + 1 i+1 with capacity c i c_i ci?.

For each i i i from 1 1 1 to n n n in this order, the following happens:

  1. The wizard in front of water tower i i i removes at most b i b_i bi? liters of water from the tower and turns the removed water into wine.
  2. If i ≠ n i \neq n i=n, at most c i c_i ci? liters of the remaining water left in water tower i i i flows through the valve into water tower i + 1 i + 1 i+1.

There are q q q updates. In each update, you will be given integers p p p, x x x, y y y and z z z and you will update a p : = x a_p := x ap?:=x, b p : = y b_p := y bp?:=y and c p : = z c_p := z cp?:=z. After each update, find the value of W ( a , b , c ) W(a,b,c) W(a,b,c). Note that previous updates to arrays a a a, b b b and c c c persist throughout future updates.

Input

The first line contains two integers n n n and q q q ( 2 ≤ n ≤ 5 ? 1 0 5 2 \le n \le 5\cdot 10^5 2n5?105, 1 ≤ q ≤ 5 ? 1 0 5 1 \le q \le 5\cdot 10^5 1q5?105) — the number of water towers and the number of updates.

The second line contains n n n integers a 1 , a 2 , … , a n a_1, a_2, \ldots, a_n a1?,a2?,,an? ( 0 ≤ a i ≤ 1 0 9 0 \le a_i \le 10^9 0ai?109) — the number of liters of water in water tower i i i.

The third line contains n n n integers b 1 , b 2 , … , b n b_1, b_2, \ldots, b_n b1?,b2?,,bn? ( 0 ≤ b i ≤ 1 0 9 0 \le b_i \le 10^9 0bi?109) — the power of the wizard in front of water tower i i i.

The fourth line contains n ? 1 n - 1 n?1 integers c 1 , c 2 , … , c n ? 1 c_1, c_2, \ldots, c_{n - 1} c1?,c2?,,cn?1? ( c i = 1 0 18 c_i \color{red}{=} 10^{18} ci?=1018) — the capacity of the pipe connecting water tower i i i to i + 1 i + 1 i+1.

Each of the next q q q lines contains four integers p p p, x x x, y y y and z z z ( 1 ≤ p ≤ n 1 \le p \le n 1pn, 0 ≤ x , y ≤ 1 0 9 0 \le x, y \le 10^9 0x,y109, z = 1 0 18 z \color{red}{=} 10^{18} z=1018) — the updates done to arrays a a a, b b b and c c c.

Note that c n c_n cn? does not exist, so the value of z z z does not matter when p = n p = n p=n.

Output

Print q q q lines, each line containing a single integer representing W ( a , b , c ) W(a, b, c) W(a,b,c) after each update.

Example

input
4 3
3 3 3 3
1 4 2 8
1000000000000000000 1000000000000000000 1000000000000000000
4 3 8 1000000000000000000
2 5 1 1000000000000000000
3 0 0 1000000000000000000
output
12
12
10
input
5 5
10 3 8 9 2
3 4 10 8 1
1000000000000000000 1000000000000000000 1000000000000000000 1000000000000000000
5 4 9 1000000000000000000
1 1 1 1000000000000000000
2 7 4 1000000000000000000
4 1 1 1000000000000000000
1 8 3 1000000000000000000
output
34
25
29
21
27

Solution

具体见文后视频。


Code

#include <bits/stdc++.h>
#define lowbit(x) x & -x
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 5e5 + 10;

int N, Q;
int A[SIZE], B[SIZE], Pre[SIZE];
struct Segment
{
	int l, r;
	int Max, Id, Lazy;
}Tree[SIZE << 2];
struct Fenwick
{
	int Tree[SIZE];
	Fenwick() { memset(Tree, 0, sizeof Tree); }
	void Add(int x, int d) { for (int i = x; i <= N; i += lowbit(i)) Tree[i] += d; }
	int Sum(int x)
	{
		int Result = 0;
		for (int i = x; i; i -= lowbit(i))
			Result += Tree[i];
		return Result;
	}
}SA, SB;

void Pushup(int u)
{
	if (Tree[u << 1].Max > Tree[u << 1 | 1].Max) Tree[u].Id = Tree[u << 1].Id, Tree[u].Max = Tree[u << 1].Max;
	else Tree[u].Id = Tree[u << 1 | 1].Id, Tree[u].Max = Tree[u << 1 | 1].Max;
}

void Build(int u, int l, int r)
{
	if (l == r)
	{
		Tree[u] = {l, l, Pre[l], l};
		return;
	}

	Tree[u] = {l, r};
	int mid = l + r >> 1;
	Build(u << 1, l, mid), Build(u << 1 | 1, mid + 1, r);
	Pushup(u);
}

void Pushdown(int u)
{
	if (Tree[u].Lazy)
	{
		Tree[u << 1].Max += Tree[u].Lazy, Tree[u << 1].Lazy += Tree[u].Lazy;
		Tree[u << 1 | 1].Max += Tree[u].Lazy, Tree[u << 1 | 1].Lazy += Tree[u].Lazy;
		Tree[u].Lazy = 0;
	}
}

void Modify(int u, int l, int r, int d)
{
	if (Tree[u].l >= l && Tree[u].r <= r)
	{
		Tree[u].Max += d, Tree[u].Lazy += d;
		return;
	}

	Pushdown(u);
	int mid = Tree[u].l + Tree[u].r >> 1;
	if (mid >= l) Modify(u << 1, l, r, d);
	if (mid < r) Modify(u << 1 | 1, l, r, d);
	Pushup(u);
}

PII Query(int u, int l, int r)
{
	if (Tree[u].l >= l && Tree[u].r <= r)
		return {Tree[u].Max, Tree[u].Id};

	Pushdown(u);
	int mid = Tree[u].l + Tree[u].r >> 1;
	if (mid >= l && mid < r)
	{
		PII A = Query(u << 1, l, r), B = Query(u << 1 | 1, l, r), Result;
		if (A.first > B.first) Result.second = A.second, Result.first = A.first;
		else Result.second = B.second, Result.first = B.first;
		return Result;
	}
	else if (mid >= l) return Query(u << 1, l, r);
	else return Query(u << 1 | 1, l, r);
}

signed main()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(0);

	cin >> N >> Q;

	for (int i = 1; i <= N; i ++)
		cin >> A[i], SA.Add(i, A[i]);
	for (int i = 1; i <= N; i ++)
		cin >> B[i], SB.Add(i, B[i]), Pre[i] = Pre[i - 1] + B[i] - A[i];
	int C;
	for (int i = 1; i < N; i ++)
		cin >> C;

	Build(1, 1, N);

	int P, X, Y, Z;
	while (Q --)
	{
		cin >> P >> X >> Y >> Z;

		Modify(1, P, N, (Y - X) - (B[P] - A[P]));
		SA.Add(P, X - A[P]), SB.Add(P, Y - B[P]);
		A[P] = X, B[P] = Y;

		auto T = Query(1, 1, N);
		int u = T.second, Max = T.first;

		if (Max <= 0)
			cout << SB.Sum(N) << endl;
		else
			cout << SA.Sum(u) + SB.Sum(N) - SB.Sum(u) << endl;
	}

	return 0;
}

视频题解

Codeforces Hello 2024(A-D+F1)


最后祝大家早日在这里插入图片描述

文章来源:https://blog.csdn.net/weixin_66946161/article/details/135467462
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。