Atcoder Begginer Contest 327 讲解(A~E题)

这篇具有很好参考价值的文章主要介绍了Atcoder Begginer Contest 327 讲解(A~E题)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

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.
Atcoder Begginer Contest 327 讲解(A~E题),Atcoder,Atcoder,c++,ABC
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.
Atcoder Begginer Contest 327 讲解(A~E题),Atcoder,Atcoder,c++,ABC
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.
Atcoder Begginer Contest 327 讲解(A~E题),Atcoder,Atcoder,c++,ABC
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;
}

今天就到这里了!

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

吾欲您伸手,点的小赞赞。吾欲您喜欢,点得小关注!文章来源地址https://www.toymoban.com/news/detail-743161.html

到了这里,关于Atcoder Begginer Contest 327 讲解(A~E题)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • AtCoder Beginner Contest 317(A~E题)讲解

    Problem Statement Naohiro has a monster. The monster’s current health is H H H . He also has N N N kinds of potions, numbered from 1 1 1 to N N N in ascending order of effectiveness. If you give the monster potion n n n , its health will increase by P n P_n P n ​ . Here, P 1 P 2 ⋯ P N P_1 lt P_2 lt dots lt P_N P 1 ​ P 2 ​ ⋯ P N ​ . He wants

    2024年02月11日
    浏览(21)
  • Atcoder Beginner Contest 304——A-D题讲解

    蒟蒻来讲题,还望大家喜。若哪有问题,大家尽可提! Hello, 大家好哇!本 初中生蒟蒻 讲解一下 AtCoder Beginner Contest 304 这场比赛的 A-D题 ! =========================================================================================== 题目描述 Problem Statement There are N N N people numbered 1 , 2 , … , N 1, 2,

    2024年02月08日
    浏览(29)
  • AtCoder Beginner Contest 297——A-E题讲解

    蒟蒻来讲题,还望大家喜。若哪有问题,大家尽可提! Hello, 大家好哇!本 初中生蒟蒻 讲解一下 AtCoder Beginner Contest 297 这场比赛的 A-E题 ! 今晚比前面几场要简单点,但我在B题翻了下车,第一次提交竟然WA了,做题要仔细啊。 开心的是,今晚终于进到绿名了! ===============

    2024年02月03日
    浏览(26)
  • Atcoder Beginner Contest 311 C - E题讲解

    Problem Statement There is a directed graph with N N N vertices and N N N edges. The i i i -th edge goes from vertex i i i to vertex A i A_i A i ​ . (The constraints guarantee that i ≠ A i i neq A_i i  = A i ​ .) Find a directed cycle without the same vertex appearing multiple times. It can be shown that a solution exists under the constraints of t

    2024年02月15日
    浏览(22)
  • AtCoder Beginner Contest 314(A~D题 + G题)讲解

    Problem Statement The number pi to the 100 100 100 -th decimal place is 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679 . You are given an integer N N N between 1 1 1 and 100 100 100 , inclusive. Print the value of pi to the N N N -th decimal place. More precisely, truncate the value of pi to N N N decim

    2024年02月13日
    浏览(22)
  • AtCoder abc336 A~D题解

    题目翻译: 对于正整数 X X X 级别的龙串, X X X 是长度为 ( X + 3 ) (X+3) ( X + 3 ) 的字符串,由按此顺序排列的 o 、 n 和 g 的一次 L 、 X X X 次出现形成。 你得到一个正整数 N N N 。打印 N N N 级的龙串。 分析 按题目要求做即可……,输出一个 L ,循环 X X X 次输出 o ,再输出 ng 。

    2024年01月15日
    浏览(31)
  • AtCoder Beginner Contest 318

    咕咕咕,总力战还没打,凹不过卷狗,躺了.jpg 给定 (n, m, p) ,问有多少个 (i) 满足 (0 m+pi leq n) 减去初始的 (m) ,剩下的就是看 (p) 的倍数个数。 神奇的代码 一个二维空间,有 (n) 个矩形覆盖。 问有多大的空间被覆盖了。重复覆盖算一次。 空间大小只有 (100) ,矩形

    2024年02月10日
    浏览(31)
  • AtCoder Beginner Contest 322

    给定一个字符串,找到最先出现 ABC 的位置。 直接查找判断即可。 神奇的代码 给定字符串 s 和 t ,问 s 是不是 t 的前缀和后缀。 根据前后缀定义判断即可。这里试了下 python 神奇的代码 (n) 天,有 (m) 天会放烟花。 问每一天,距离未来最近的放烟花的天数。 两个双指针一

    2024年02月08日
    浏览(21)
  • AtCoder Beginner Contest 336

    给定一个数 (n) ,将 long 中的 o 重复 (n) 次后输出。 模拟即可。 神奇的代码 给定一个数 (n) ,问 (n) 的二进制表示下的末尾零的数量。 即找到最小的 (i) 使得 (n (1 i)) 不为零的位置。枚举即可。 或者直接用内置函数 __builtin_ctz 。(count tail zero? 神奇的代码 定义一个数

    2024年01月20日
    浏览(32)
  • AtCoder Beginner Contest 326

    100楼层,一次可以上最多两层,或下最多三层。 给定两楼层,问能否一次到达。 比较大小,然后判断其差是是不是在 (2) 或 (3) 内即可。 神奇的代码 给定一个 (n) ,问不小于 (n) 的形如 (326) 的数字是多少。 形如 (326) 的数字,即数位有 (3) ,且百位 (times) 十位

    2024年02月08日
    浏览(23)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包