代码编织梦想

A - ab

Description

Problem Statement

You are given a string S S S of length N N N consisting of lowercase English letters.
If there are any adjacent occurrences of a and b in S S S, print Yes; otherwise, print No. (The order of a and b does not matter.)

问题陈述

给你一个长度为 N N N 的字符串 S S S ,由小写英文字母组成。
如果在 S S S中出现相邻的ab,打印;否则,打印。(a "和 "b "的顺序并不重要)。

Constraints
  • 2 ≤ N ≤ 100 2 \leq N \leq 100 2N100
  • S S S is a string of length N N N consisting of lowercase English letters.
Input

The input is given from Standard Input in the following format:

N N N
S S S

Output

If there are any adjacent occurrences of a and b in S S S, print Yes; otherwise, print No.

Sample Input 1
3
abc
Sample Output 1
Yes

The string abc has a as the first character and b as the second character, which are adjacent. Thus, print Yes.

Sample Input 2
2
ba
Sample Output 2
Yes

The string ba has a as the second character and b as the first character, which are adjacent. (Note that the order of a and b does not matter.)

Sample Input 3
7
atcoder
Sample Output 3
No

Solution

ABC327 A题


Code

#include <iostream>
#define int long long

using namespace std;

typedef pair<int, int> PII;

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

	int N;
	string S;

	cin >> N >> S;

	for (int i = 1; i < S.size(); i ++)
		if (S[i] == 'a' && S[i - 1] == 'b' || S[i - 1] == 'a' && S[i] == 'b')
		{
			cout << "Yes" << endl;
			return 0;
		}

	cout << "No" << endl;

	return 0;
}

B - A^A

Description

Problem Statement

You are given an integer B B B.

If there exists a positive integer A A A such that A A = B A^A = B AA=B, print its value; otherwise, output -1.

问题陈述

给你一个整数 B B B
如果存在一个正整数 A A A,使得 A A = B A^A = B AA=B,打印它的值,否则,输出-1

Constraints

1 ≤ B ≤ 1 0 18 1 \leq B \leq 10^{18} 1B1018
B B B is an integer.

Input

The input is given from Standard Input in the following format:

B B B

Output

If there exists a positive integer A A A such that A A = B A^A = B AA=B, print its value; otherwise, print -1.

If there are multiple positive integers A A A such that A A = B A^A = B AA=B, any of them will be accepted.

Sample Input 1
27
Sample Output 1
3

3 3 = 27 3^3 = 27 33=27, so print 3 3 3.

Sample Input 2
100
Sample Output 2
-1

There is no A A A such that A A = B A^A = B AA=B.

Sample Input 3
10000000000
Sample Output 3
10

Solution

ABC327 B题


Code

#include <iostream>
#define int long long

using namespace std;

typedef pair<int, int> PII;

__int128 qmi(int a, int b)
{
	__int128 Result = 1;
	while (b)
	{
		if (b & 1) Result = Result * a;
		a = a * a;
		b >>= 1;
	}

	return Result;
}

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

	int B;

	cin >> B;

	int A = 1;
	for (; qmi(A, A) <= B; A ++)
		if (qmi(A, A) == B)
		{
			cout << A << endl;
			return 0;
		}

	cout << -1 << endl;

	return 0;
}

C - Number Place

Description

Problem Statement

There is a 9 × 9 9\times 9 9×9 grid A A A, where each cell contains an integer between 1 1 1 and 9 9 9, inclusive.

Specifically, the cell at the i i i-th row from the top and j j j-th column from the left contains A i , j A_{i,j} Ai,j.
If A A A satisfies all of the following conditions, print Yes. Otherwise, print No.
For each row of A A A, the nine cells in that row contain each integer from 1 1 1 to 9 9 9 exactly once.
For each column of A A A, the nine cells in that column contain each integer from 1 1 1 to 9 9 9 exactly once.
Divide the rows of A A A into three groups, each of three rows, from top to bottom, and similarly divide the columns into three groups, each of three columns, from left to right.
Each 3 × 3 3\times 3 3×3 grid obtained from A A A in this way contains each integer from 1 1 1 to 9 9 9 exactly once.

问题陈述

有一个 9 × 9 9\times 9 9×9网格 A A A,其中每个单元格都包含一个介于 1 1 1 9 9 9(含)之间的整数。
具体来说,从顶部起第 i i i行和从左侧起第 j j j列的单元格中包含 A i , j A_{i,j} Ai,j

如果 A A A 满足以下所有条件,则打印 “是”。否则,打印 “否”。

  • 对于 A A A的每一行,该行中的九个单元格包含了从 1 1 1 9 9 9的每一个整数。
  • 对于 A A A 的每一列,该列中的九个单元格包含了从 1 1 1 9 9 9 的每一个整数。
  • A A A的行从上到下分成三组,每组三行,同样将列从左到右分成三组,每组三列。这样从 A A A得到的每个 3 × 3 3\times 3 3×3网格正好包含一次从 1 1 1 9 9 9的每个整数。
Constraints

1 ≤ A i , j ≤ 9 1\leq A_{i,j}\leq 9 1Ai,j9
All input values are integers.

Input

The input is given from Standard Input in the following format:

A 1 , 1 A_{1,1} A1,1 A 1 , 2 A_{1,2} A1,2 … \ldots A 1 , 9 A_{1,9} A1,9
A 2 , 1 A_{2,1} A2,1 A 2 , 2 A_{2,2} A2,2 … \ldots A 2 , 9 A_{2,9} A2,9
⋮ \vdots
A 9 , 1 A_{9,1} A9,1 A 9 , 2 A_{9,2} A9,2 … \ldots A 9 , 9 A_{9,9} A9,9

Output

If the grid A A A satisfies all the conditions in the problem statement, print Yes; otherwise, print No.

Sample Input 1
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
2 3 4 5 6 7 8 9 1
5 6 7 8 9 1 2 3 4
8 9 1 2 3 4 5 6 7
3 4 5 6 7 8 9 1 2
6 7 8 9 1 2 3 4 5
9 1 2 3 4 5 6 7 8
Sample Output 1
Yes

The grid A A A is shown below.
620efb8d15cafdf787ee4a99edbb9995.png
The grid A A A satisfies all three conditions, so print Yes.

Sample Input 2
1 2 3 4 5 6 7 8 9
2 3 4 5 6 7 8 9 1
3 4 5 6 7 8 9 1 2
4 5 6 7 8 9 1 2 3
5 6 7 8 9 1 2 3 4
6 7 8 9 1 2 3 4 5
7 8 9 1 2 3 4 5 6
8 9 1 2 3 4 5 6 7
9 1 2 3 4 5 6 7 8
Sample Output 2
No

The grid A A A is shown below.
9b1eb989cb732011f69c1e37484f6b5a.png
For example, if you look at the top left 3 × 3 3\times 3 3×3 grid, you can see that the third condition is unsatisfied, so print No.

Sample Input 3
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
1 2 3 4 5 6 7 8 9
4 5 6 7 8 9 1 2 3
7 8 9 1 2 3 4 5 6
Sample Output 3
No

The grid A A A is shown below.
2bb8fb897448850e1826e487941d1ccf.png
For example, if you look at the leftmost column, you can see that the second condition is unsatisfied, so print No.

Solution

ABC327 C题


Code

#include <iostream>
#define int long long

using namespace std;

typedef pair<int, int> PII;

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

	int A[10][10];

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

	for (int i = 1; i <= 9; i ++)
	{
		int Tmp = 0;
		for (int j = 1; j <= 9; j ++)
			Tmp |= (1 << A[i][j] - 1);
		if (Tmp != 511)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 1; i <= 9; i ++)
	{
		int Tmp = 0;
		for (int j = 1; j <= 9; j ++)
			Tmp |= (1 << A[j][i] - 1);
		if (Tmp != 511)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	for (int i = 1; i <= 9; i += 3)
		for (int j = 1; j <= 9; j += 3)
		{
			int Tmp = 0;
			for (int x = i; x <= i + 2; x ++)
				for (int y = j; y <= j + 2; y ++)
					Tmp |= (1 << A[x][y] - 1);
			if (Tmp != 511)
			{
				cout << "No" << endl;
				return 0;
			}
		}

	cout << "Yes" << endl;

	return 0;
}

D - Good Tuple Problem

Description

Problem Statement

A pair of sequences of length M M M consisting of positive integers at most N N N, ( S , T ) = ( ( S 1 , S 2 , … , S M ) , ( T 1 , T 2 , … , T M ) ) (S, T) = ((S_1, S_2, \dots, S_M), (T_1, T_2, \dots, T_M)) (S,T)=((S1,S2,,SM),(T1,T2,,TM)), is said to be a good pair of sequences when ( S , T ) (S, T) (S,T) satisfies the following condition.
There exists a sequence X = ( X 1 , X 2 , … , X N ) X = (X_1, X_2, \dots, X_N) X=(X1,X2,,XN) of length N N N consisting of 0 0 0 and 1 1 1 that satisfies the following condition:
X S i ≠ X T i X_{S_i} \neq X_{T_i} XSi=XTi for each i = 1 , 2 , … , M i=1, 2, \dots, M i=1,2,,M.
You are given a pair of sequences of length M M M consisting of positive integers at most N N N: ( A , B ) = ( ( A 1 , A 2 , … , A M ) , ( B 1 , B 2 , … , B M ) ) (A, B) = ((A_1, A_2, \dots, A_M), (B_1, B_2, \dots, B_M)) (A,B)=((A1,A2,,AM),(B1,B2,,BM)). If ( A , B ) (A, B) (A,B) is a good pair of sequences, print Yes; otherwise, print No.

Constraints

1 ≤ N , M ≤ 2 × 1 0 5 1 \leq N, M \leq 2 \times 10^5 1N,M2×105
1 ≤ A i , B i ≤ N 1 \leq A_i, B_i \leq N 1Ai,BiN
All input values are integers.

Input

The input is given from Standard Input in the following format:

N N N M M M
A 1 A_1 A1 A 2 A_2 A2 … \dots A M A_M AM
B 1 B_1 B1 B 2 B_2 B2 … \dots B M B_M BM

Output

If ( A , B ) (A, B) (A,B) is a good pair of sequences, print Yes; otherwise, print No.

Sample Input 1
3 2
1 2
2 3
Sample Output 1
Yes

If we set X = ( 0 , 1 , 0 ) X=(0,1,0) X=(0,1,0), then X X X is a sequence of length N N N consisting of 0 0 0 and 1 1 1 that satisfies X A 1 ≠ X B 1 X_{A_1} \neq X_{B_1} XA1=XB1 and X A 2 ≠ X B 2 X_{A_2} \neq X_{B_2} XA2=XB2.

Thus, ( A , B ) (A, B) (A,B) satisfies the condition of being a good pair of sequences.

Sample Input 2
3 3
1 2 3
2 3 1
Sample Output 2
No

No sequence X X X satisfies the condition, so ( A , B ) (A, B) (A,B) is not a good pair of sequences.

Sample Input 3
10 1
1
1
Sample Output 3
No
Sample Input 4
7 8
1 6 2 7 5 4 2 2
3 2 7 2 1 2 3 3
Sample Output 4
Yes

Solution

ABC327 D题


Code

#include <iostream>
#include <vector>
#include <map>
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 2e5 + 10;

int N, M;
int A[SIZE], B[SIZE];
vector<int> G[SIZE];
int Color[SIZE];

bool DFS(int u, int color)
{
    Color[u] = color;
    
    for (auto c : G[u])
    {
        if (!Color[c])
            if (!DFS(c, 3 - color))
                return false;
        if (Color[c] == color)
            return false;
    }
    
    return true;
}

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

	cin >> N >> M;

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

	for (int i = 1; i <= M; i ++)
		if (A[i] == B[i])
		{
			cout << "No" << endl;
			return 0;
		}
		else
			G[A[i]].push_back(B[i]), G[B[i]].push_back(A[i]);

	// for (auto c : Edge)
	// 	cout << c.first << " " << c.second << endl;

	bool Flag = 1;
    for (int i = 1; i <= N; i ++)
        if (!Color[i])
            if (!DFS(i, 1))
            {
                cout << "No" << endl;
                return 0;
            }

    cout << "Yes" << endl;

	return 0;
}

E - Maximize Rating

Description

Problem Statement

Takahashi participated in N N N contests and earned a performance P i P_i Pi in the i i i-th contest.

He wants to choose some (at least one) contests from these and maximize his rating calculated from the results of those contests.
Find the maximum possible rating he can achieve by optimally choosing the contests.
Here, Takahashi’s rating R R R is calculated as the following, where k k k is the number of chosen contests and ( Q 1 , Q 2 , … , Q k ) (Q_1, Q_2, \ldots, Q_k) (Q1,Q2,,Qk) are the performances in the chosen contests in the order he participated:

R = ∑ i = 1 k ( 0.9 ) k − i Q i ∑ i = 1 k ( 0.9 ) k − i − 1200 k . \displaystyle R=\frac{\sum_{i=1}^k (0.9)^{k-i}Q_i}{\sum_{i=1}^k (0.9)^{k-i}}-\frac{1200}{\sqrt{k}}. R=i=1k(0.9)kii=1k(0.9)kiQik 1200.

问题陈述

高桥参加了 N N N 次比赛,并在 i i i 次比赛中获得了 P i P_i Pi 的成绩。
他想从中选择一些(至少一个)比赛,并最大限度地提高根据这些比赛结果计算出的评分。

求通过优化选择比赛他能获得的最高评分。

这里,高桥的评分 R R R计算如下,其中 k k k是所选比赛的数量, ( Q 1 , Q 2 , … , Q k ) (Q_1, Q_2, \ldots, Q_k) (Q1,Q2,,Qk)是所选比赛的成绩,按他参加比赛的顺序:

R = ∑ i = 1 k ( 0.9 ) k − i Q i ∑ i = 1 k ( 0.9 ) k − i − 1200 k . \displaystyle R=\frac{\sum_{i=1}^k (0.9)^{k-i}Q_i}{\sum_{i=1}^k (0.9)^{k-i}}-\frac{1200}{\sqrt{k}}. R=i=1k(0.9)kii=1k(0.9)kiQik 1200.

Constraints

1 ≤ N ≤ 5000 1\leq N\leq 5000 1N5000
1 ≤ P i ≤ 5000 1\leq P_i\leq 5000 1Pi5000
All input values are integers.

Input

The input is given from Standard Input in the following format:

N N N
P 1 P_1 P1 P 2 P_2 P2 … \ldots P N P_N PN

Output

Print the maximum possible rating that Takahashi can achieve.

Your output will be considered correct if the absolute or relative error from the true value is at most 1 0 − 6 10^{-6} 106.

Sample Input 1
3
1000 600 1200
Sample Output 1
256.735020470879931

If Takahashi chooses the first and third contests, his rating will be:
R = 0.9 × 1000 + 1.0 × 1200 0.9 + 1.0 − 1200 2 = 256.73502... \displaystyle R=\frac{0.9\times 1000+ 1.0\times 1200}{0.9+1.0}-\frac{1200}{\sqrt{2}}=256.73502... R=0.9+1.00.9×1000+1.0×12002 1200=256.73502....
This is the maximum possible rating.

Sample Input 2
3
600 1000 1200
Sample Output 2
261.423219407873376

The rating is maximized when all the first, second, and third contests are selected.

Sample Input 3
1
100
Sample Output 3
-1100.000000000000000

The rating can also be negative.

Solution

ABC327 E题


Code

#include <iostream>
#include <cmath>
#include <cstring>
#include <ctime>

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 1e4 + 10;

int N;
int P[SIZE];
double F[SIZE][SIZE], Max[SIZE][SIZE], Pow[SIZE];

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

	cin >> N;

	Pow[0] = 1.0;
	for (int i = 1; i <= N; i ++)
		Pow[i] = Pow[i - 1] * 0.9;

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

	for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= N; j ++)
			F[i][j] = Max[i][j] = 0.0;
	for (int i = 1; i <= N; i ++)
		for (int j = 1; j <= i; j ++)
		{
			F[i][j] = max(F[i][j], F[i - 1][j]);
			F[i][j] = max(F[i][j], Max[i - 1][j - 1] * 0.9 + P[i]);
			Max[i][j] = max(Max[i - 1][j], F[i][j]);
		}

	double Answer = -1e18;
	for (int k = 1; k <= N; k ++)
	{
		double Result = -1e18;
		for (int i = 1; i <= N; i ++)
			Result = max(Result, F[i][k]);
		double Tmp = 0;
		for (int i = 1; i <= k; i ++)
			Tmp += Pow[k - i];
		Result /= Tmp;
		Result -= (1200.0 / sqrt(k * 1.0));
		Answer = max(Answer, Result);
	}

	printf("%.6lf\n", Answer);

	return 0;
}

F - Apples

Description

Problem Statement

There are apple trees lined up on a number line, and N N N apples fall from the trees.

Specifically, for each 1 ≤ i ≤ N 1\leq i\leq N 1iN, an apple falls at coordinate X i X_i Xi at time T i T_i Ti.
Takahashi has a basket with durability D D D and length W W W, and he can take the following action exactly once.

Choose positive integers S S S and L L L. He sets up the basket to cover the range L − 0.5 ≤ x ≤ L + W − 0.5 L-0.5\leq x\leq L+W-0.5 L0.5xL+W0.5 at time S − 0.5 S-0.5 S0.5, and retrieves it at time S + D − 0.5 S+D-0.5 S+D0.5.
He gets all the apples that fell into the range covered by the basket between the time it was set up and the time it was retrieved.

He cannot move the basket once it has been set up, nor can he set it up again once it has been retrieved.

Find the maximum number of apples that he can get.

Constraints

1 ≤ N ≤ 2 × 1 0 5 1 \leq N\leq 2\times 10^5 1N2×105
1 ≤ D ≤ 2 × 1 0 5 1 \leq D\leq 2\times 10^5 1D2×105
1 ≤ W ≤ 2 × 1 0 5 1 \leq W\leq 2\times 10^5 1W2×105
1 ≤ T i ≤ 2 × 1 0 5 1 \leq T_i\leq 2\times 10^5 1Ti2×105
1 ≤ X i ≤ 2 × 1 0 5 1 \leq X_i\leq 2\times 10^5 1Xi2×105
All pairs ( T i , X i ) (T_i,X_i) (Ti,Xi) are different.
All input values are integers.

Input

The input is given from Standard Input in the following format:

N N N D D D W W W
T 1 T_1 T1 X 1 X_1 X1
T 2 T_2 T2 X 2 X_2 X2
⋮ \vdots
T N T_N TN X N X_N XN

Output

Print the maximum number of apples that Takahashi can get.

Sample Input 1
8 4 3
1 1
3 4
6 4
5 2
4 2
4 3
5 5
7 3
Sample Output 1
5

If Takahashi chooses S = 3 S=3 S=3 and L = 2 L=2 L=2, he will set up the basket to cover the range 1.5 ≤ x ≤ 4.5 1.5\leq x\leq 4.5 1.5x4.5 from time 2.5 2.5 2.5 to 6.5 6.5 6.5. Then, he gets the following five apples:
The apple that falls at coordinate X 2 = 4 X_2=4 X2=4 at time T 2 = 3 T_2=3 T2=3
The apple that falls at coordinate X 3 = 4 X_3=4 X3=4 at time T 3 = 6 T_3=6 T3=6
The apple that falls at coordinate X 4 = 2 X_4=2 X4=2 at time T 4 = 5 T_4=5 T4=5
The apple that falls at coordinate X 5 = 2 X_5=2 X5=2 at time T 5 = 4 T_5=4 T5=4
The apple that falls at coordinate X 6 = 3 X_6=3 X6=3 at time T 6 = 4 T_6=4 T6=4
There is no way to get six or more apples, so print 5 5 5.

问题陈述

有几棵苹果树排在一条数线上, N N N个苹果从树上掉下来。
具体地说,每一个 1 ≤ i ≤ N 1\leq i\leq N 1iN 都有一个苹果在时间 T i T_i Ti 落在坐标 X i X_i Xi 处。

高桥有一个耐久度为 D D D、长度为 W W W的篮子,他可以做以下动作

选择正整数 S S S L L L。他在 S − 0.5 S-0.5 S0.5时将篮子放置在 L − 0.5 ≤ x ≤ L + W − 0.5 L-0.5\leq x\leq L+W-0.5 L0.5xL+W0.5范围内,在 S + D − 0.5 S+D-0.5 S+D0.5时将其取回。他可以得到从放置篮子到取回篮子这段时间内掉落在篮子覆盖范围内的所有苹果。

篮子放好后,他不能移动篮子,篮子取回后,他也不能再放篮子。
求他能得到的苹果的最大数量。

Solution

ABC327 F题


Code

#include <iostream>
#include <algorithm>
#define int long long

using namespace std;

typedef pair<int, int> PII;

const int SIZE = 2e5 + 10;

int N, D, W;
PII P[SIZE];
struct Segment
{
	int l, r;
	int Max, Lazy;
}Tree[SIZE * 4];

void Pushup(int u)
{
	Tree[u].Max = max(Tree[u << 1].Max, Tree[u << 1 | 1].Max);
}

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

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

	int mid = l + r >> 1;
	Build(u << 1, l, mid), Build(u << 1 | 1, mid + 1, r);
}

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);
}

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

	Pushdown(u);
	int mid = Tree[u].l + Tree[u].r >> 1, Result = 0;
	if (mid >= l) Result = Query(u << 1, l, r);
	if (mid < r) Result = max(Result, Query(u << 1 | 1, l, r));

	return Result;
}

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

	cin >> N >> D >> W;

	int Time = 0, Pos = 0;
	for (int i = 1; i <= N; i ++)
		cin >> P[i].first >> P[i].second, Time = max(Time, P[i].first), Pos = max(Pos, P[i].second);

	sort(P + 1, P + 1 + N);

	Build(1, 1, Time);

	int j = 1;
	for (int i = 1; i <= D; i ++)
		while (P[j].first == i && j <= N)
		{
			Modify(1, max(1ll, P[j].second - W + 1), P[j].second, 1);
			j ++;
		}

	int j2 = 1, Result = Query(1, 1, Pos);
	for (int i = D + 1; i <= Time; i ++)
	{
		while (P[j2].first == i - D && j2 <= N)
		{
			Modify(1, max(1ll, P[j2].second - W + 1), P[j2].second, -1);
			j2 ++;
		}
		while (P[j].first == i && j <= N)
		{
			Modify(1, max(1ll, P[j].second - W + 1), P[j].second, 1);
			j ++;
		}
		Result = max(Result, Query(1, 1, Pos));
	}

	cout << Result << endl;

	return 0;
}

今天就到这里了!

大家有什么问题尽管提,我都会尽力回答的!

吾欲您伸手,点的小赞赞。吾欲您喜欢,点得小关注!

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_66946161/article/details/134226928

高级英语词汇总结-爱代码爱编程

Chapter 1 detriment/ˈdetrɪmənt/n. 伤害; 损害; 造成伤害(或损害)的事物; 不利因素something that causes damage, harm, or lesseg. Loni’s purple hair may be a detriment when she goes for a job interview

yolov5全面解析教程(一):网络结构逐行代码解析_奥比中光3d视觉开发者社区的博客-爱代码爱编程

作者|Fengwen,BBuf  编辑|3D视觉开发者社区 引言 YOLOv5针对不同大小(n, s, m, l, x)的网络整体架构都是一样的,只不过会在每个子模块中采用不同的深度和宽度,分别应对yaml文件中的depth_multiple和width_multiple参数。 还需要注意一点,官方除了n, s, m, l, x版本外还

mongodb 聚合管道运算符(算术运算符)-爱代码爱编程

算术表达式运算符主要用于实现数字之间的算术运算,主要包含了对加、减、乘、除、余数、截取、舍入等算术操作。 下面我们进行详细介绍: 一、准备数据 初始化商品数据 db.goods.insertMany([ { "_id": 1, name: "薯片", size: "S", quantity: 10, sale: 50, price: 8,

使用 cmake 和 ninja 构建 c/c++ 项目的教程-爱代码爱编程

使用 CMake 和 Ninja 构建 C/C++ 项目的教程 CMake 是一个跨平台的开源构建工具,它简化了项目的构建过程。而 Ninja 是一个快速、轻量级的构建系统,与 CMake 配合使用可以提高项目的构建效率。

【c++】内存对齐-爱代码爱编程

本篇文章介绍C++中的内存对齐,后续介绍C的union和C++的variant的时候,需要用到这部分的知识。 占用内存 先回忆下C++各个数据类型占用的内存大小: int:所占内存大小:4byte = 32bit;ch

atcoder beginner contest 327(a~f)题解 abc327_atcoder abc327-爱代码爱编程

AtCoder Beginner Contest 327 A - ab 就是看子串中是否包含ab 或ba 时间复杂度 O

abc327 d-爱代码爱编程

比赛链接 D - Good Tuple Problem tag:并查集 类似题目: 活动 - AcWingc  错误原因: 在更新儿子节点的距离的时候,是直接进行更新,这是错误操作,应该先对父节点进行一次find,确保父节点更新为最终状态后,才能对其进行更新,否则就会出现,按照父节点的距离进行更新后,然后连到祖宗节点,这就会产生错误。 题解:

ue5 c++(十五)— timerhandle(定时器)的使用-爱代码爱编程

文章目录 设置定时器声明FTimerHandle定义执行函数设置定时器 清除定时器 定时器(Timer) 可用于执行延迟类型的操作,或让某些操作在一段时间内重复执行。 设置定时器 定

12. c++ kmalloc、kzalloc、vmalloc的区别-爱代码爱编程

kmalloc、kzalloc、vmalloc的区别 我们都知道在用户空间动态申请内存用的函数是 malloc(),这个函数在各种操作系统上的使用是一致的,对应的用户空间内存释放函数是 free()。注意:动态申请的内存使